@orangecharts/wrun-chart-host 0.7.0 → 0.8.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 (125) hide show
  1. package/README.md +25 -2
  2. package/dist/constants/feature-flags.constants.d.ts +1 -0
  3. package/dist/constants/feature-flags.constants.js +5 -0
  4. package/dist/constants/option-venues.constants.d.ts +18 -0
  5. package/dist/constants/option-venues.constants.js +14 -0
  6. package/dist/constants/venue-presets.constants.d.ts +17 -3
  7. package/dist/constants/venue-presets.constants.js +17 -3
  8. package/dist/host-env.d.ts +24 -0
  9. package/dist/host-env.js +21 -0
  10. package/dist/host-ports.types.d.ts +12 -0
  11. package/dist/index.d.ts +16 -0
  12. package/dist/index.js +16 -0
  13. package/dist/indicators/controls/tpo-session.util.d.ts +40 -11
  14. package/dist/indicators/controls/tpo-session.util.js +138 -14
  15. package/dist/interfaces/option-instrument.interface.d.ts +6 -0
  16. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +4 -0
  17. package/dist/kscript-data/controls/live-trades-merge.util.js +4 -0
  18. package/dist/settings-templates/footprint-rows.d.ts +25 -0
  19. package/dist/settings-templates/footprint-rows.js +127 -0
  20. package/dist/settings-templates/form-rows.d.ts +56 -0
  21. package/dist/settings-templates/form-rows.js +19 -0
  22. package/dist/settings-templates/frvp-fields.js +14 -0
  23. package/dist/settings-templates/index.d.ts +11 -0
  24. package/dist/settings-templates/index.js +29 -6
  25. package/dist/settings-templates/indicator-fields.d.ts +2 -0
  26. package/dist/settings-templates/indicator-fields.js +78 -0
  27. package/dist/settings-templates/tool-rules.d.ts +40 -4
  28. package/dist/settings-templates/tool-rules.js +45 -4
  29. package/dist/settings-templates/tool-tables.generated.js +22 -2
  30. package/dist/utility/chart/candle-volume-unit.leaf.d.ts +16 -0
  31. package/dist/utility/chart/candle-volume-unit.leaf.js +61 -0
  32. package/dist/utility/chart/footprint-columns.util.d.ts +74 -0
  33. package/dist/utility/chart/footprint-columns.util.js +106 -0
  34. package/dist/utility/chart/footprint-display-mode.util.d.ts +40 -0
  35. package/dist/utility/chart/footprint-display-mode.util.js +62 -0
  36. package/dist/utility/chart/footprint-sierra-look.util.d.ts +2 -0
  37. package/dist/utility/chart/footprint-sierra-look.util.js +37 -0
  38. package/dist/utility/chart/kscript-venue-policy.util.js +4 -2
  39. package/dist/utility/chart/om-panel.util.d.ts +11 -0
  40. package/dist/utility/chart/om-panel.util.js +59 -0
  41. package/dist/utility/chart/window-geometry.leaf.d.ts +23 -1
  42. package/dist/utility/chart/window-geometry.leaf.js +78 -6
  43. package/dist/utility/chart/window-owner.leaf.d.ts +13 -0
  44. package/dist/utility/chart/window-owner.leaf.js +5 -0
  45. package/dist/utility/options/cme-options-root.util.d.ts +25 -0
  46. package/dist/utility/options/cme-options-root.util.js +40 -0
  47. package/dist/utility/options/option-book.util.d.ts +27 -0
  48. package/dist/utility/options/option-book.util.js +76 -0
  49. package/dist/utility/options/option-trade-date.util.d.ts +50 -0
  50. package/dist/utility/options/option-trade-date.util.js +120 -0
  51. package/dist/utility/wrun/sources/host-grid-landing.d.ts +4 -2
  52. package/dist/utility/wrun/sources/host-grid-landing.js +8 -0
  53. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +40 -4
  54. package/dist/utility/wrun/sources/lanes/options_flow.js +115 -18
  55. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +12 -9
  56. package/dist/utility/wrun/sources/opra-option-lanes.util.js +10 -7
  57. package/dist/utility/wrun/sources/row-lane-registry.js +9 -5
  58. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  59. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +3 -2
  60. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +30 -5
  61. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +14 -1
  62. package/dist/utility/wrun/sources/row-lanes/option_prints.js +100 -23
  63. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.d.ts +4 -0
  64. package/dist/utility/wrun/sources/row-lanes/option_strike_flow.js +65 -0
  65. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +47 -1
  66. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +71 -2
  67. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +14 -1
  68. package/dist/utility/wrun/sources/row-lanes/option_surface.js +30 -2
  69. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +7 -1
  70. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +45 -5
  71. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +115 -3
  72. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.d.ts +10 -0
  73. package/dist/utility/wrun/sources/wrun-row-lane-first-paint.util.js +57 -0
  74. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +60 -6
  75. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +160 -23
  76. package/dist/utility/wrun/wrun-cloud-record.leaf.d.ts +27 -0
  77. package/dist/utility/wrun/wrun-cloud-record.leaf.js +71 -0
  78. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +4 -21
  79. package/dist/utility/wrun/wrun-cloud-record.util.js +5 -65
  80. package/dist/utility/wrun/wrun-color-settings.util.d.ts +7 -5
  81. package/dist/utility/wrun/wrun-color-settings.util.js +26 -11
  82. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +4 -2
  83. package/dist/utility/wrun/wrun-draft-overlay.util.js +40 -3
  84. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
  85. package/dist/utility/wrun/wrun-hosted-wire-caps.js +4 -0
  86. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +29 -3
  87. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +33 -3
  88. package/dist/utility/wrun/wrun-live-tick.util.d.ts +4 -1
  89. package/dist/utility/wrun/wrun-live-tick.util.js +39 -6
  90. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +106 -0
  91. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +159 -0
  92. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +44 -0
  93. package/dist/utility/wrun/wrun-market-size-defaults.util.js +213 -0
  94. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +43 -8
  95. package/dist/utility/wrun/wrun-opra-flow.leaf.js +37 -6
  96. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +51 -10
  97. package/dist/utility/wrun/wrun-option-contract-flow.util.js +85 -33
  98. package/dist/utility/wrun/wrun-option-prints.util.d.ts +133 -3
  99. package/dist/utility/wrun/wrun-option-prints.util.js +318 -8
  100. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.d.ts +96 -0
  101. package/dist/utility/wrun/wrun-option-strike-flow-lane.util.js +215 -0
  102. package/dist/utility/wrun/wrun-option-strike-flow.util.d.ts +342 -0
  103. package/dist/utility/wrun/wrun-option-strike-flow.util.js +742 -0
  104. package/dist/utility/wrun/wrun-option-views.util.d.ts +183 -3
  105. package/dist/utility/wrun/wrun-option-views.util.js +504 -7
  106. package/dist/utility/wrun/wrun-options-chain.util.d.ts +6 -4
  107. package/dist/utility/wrun/wrun-options-chain.util.js +8 -5
  108. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +2 -1
  109. package/dist/utility/wrun/wrun-overlay-recovery.util.js +7 -2
  110. package/dist/utility/wrun/wrun-overlay-run.util.js +120 -18
  111. package/dist/utility/wrun/wrun-pack-widths.leaf.d.ts +15 -0
  112. package/dist/utility/wrun/wrun-pack-widths.leaf.js +22 -0
  113. package/dist/utility/wrun/wrun-pack.util.d.ts +9 -8
  114. package/dist/utility/wrun/wrun-pack.util.js +21 -15
  115. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +4 -0
  116. package/dist/utility/wrun/wrun-panel-mount.util.js +62 -22
  117. package/dist/utility/wrun/wrun-panel-style.util.d.ts +17 -2
  118. package/dist/utility/wrun/wrun-panel-style.util.js +47 -9
  119. package/dist/utility/wrun/wrun-pin-spelling.util.js +19 -10
  120. package/dist/utility/wrun/wrun-refusal.util.js +7 -1
  121. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -0
  122. package/dist/utility/wrun/wrun-script-inputs.util.js +43 -0
  123. package/dist/utility/wrun/wrun-tape-source.util.d.ts +9 -0
  124. package/dist/utility/wrun/wrun-tape-source.util.js +18 -0
  125. package/package.json +3 -3
@@ -33,11 +33,26 @@
33
33
  * `expiries` ("all", or "nearest:N": the N earliest expiries each bar's snapshot lists, kept per input before the
34
34
  * packer judges `max_cells`, never a fetch facet). A market pin, `history` and `min_size` are refused by name; a
35
35
  * block over `max_cells` refuses the run (wrun_cell_block_too_large, never truncated). One chain per package.
36
+ * - `fold` "kit" (OPTLOAD G5, kit 0.90.0; wrun-option-views.util): `nearest`, `window_pct` (required), `lens`,
37
+ * `step_rows` (required), `carry` and `levels`, refused by the SDK's rules by name (`wrun_option_knob_invalid`); its
38
+ * `expiries` word is "all" or none (kit 0.91.1: the fold keeps its expiries with its own `nearest`, any other word
39
+ * refused at declaration). Each bar reads the fold of its newest
40
+ * minute, 14-value rows (`[1, totals..., max_pain, zero_gamma, call_wall, put_wall, spot, refused]` when `levels`,
41
+ * then `[0, strike, value]` at the strikes the template draws), asked of the gateway at the chart's bars
42
+ * (`strikeKitFold` and its params, `strikeMaxCells` the input's `max_cells`) and folded by the worker by the same
43
+ * rules while the gateway refuses the read. A bar whose newest minute held more rows than `max_cells` answers its
44
+ * levels row refused, and that refuses the run (wrun_cell_block_too_large), as a block over `max_cells` does today;
45
+ * an input declaring `missing: "empty"` reads that bar empty instead (C1.2b). The run carries the 14-value rows: the
46
+ * lane's plan, the packer and the shared aligner (kit 0.91.1) size the block by the input's width
47
+ * (`WRUN_OPTION_STRIKES_KIT_SERVED`).
48
+ * - O1 (OPTLOAD G5): on the OPRA plane the chain is the plane's own by coin (`wrunHeldOpraPlaneChain`), no chain
49
+ * directory read.
36
50
  *
37
51
  * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
38
52
  */
39
53
  import { decideWrunLaneChain, decideWrunLaneChainIdentity, refuseWrunLaneStrayKnob, resolveWrunLaneChainChart, WRUN_OPTION_CHART_UNRESOLVED_CODE, wrunLaneChainLeadMoved, wrunLaneChainRefusalError, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
40
54
  import { refuseWrunPollInput } from '../wrun-poll-lane.types.js';
55
+ import { WRUN_OPTION_STRIKES_KIT_LAYOUTS, WRUN_OPTION_STRIKES_KIT_REFUSED_COLUMN, wrunHeldOpraPlaneChain, wrunOptionLaneAskFields, wrunOptionLaneAskOfSource, } from '../../wrun-option-views.util.js';
41
56
  import { WRUN_OPTIONS_CHAIN_EXPIRIES_CODE, wrunOptionsChainExpiries, wrunOptionsChainIdentityKey, } from '../../wrun-options-chain.util.js';
42
57
  import { attachWrunRefusal, wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
43
58
  /** f64s per tuple (om's `WRUN_OPTION_STRIKES_TUPLE_WIDTH`). */
@@ -107,6 +122,50 @@ export function wrunOptionStrikesExtras(chain) {
107
122
  export function wrunOptionStrikesAcquisitionMoved(acquisition) {
108
123
  return wrunLaneChainLeadMoved(acquisition[WRUN_OPTION_STRIKES_EXCHANGE_FIELD], acquisition.strikeContinuous, acquisition.strikeUnderlying);
109
124
  }
125
+ /** om's code for a block over its input's `max_cells` (wrun-pack.util `WRUN_CELL_BLOCK_TOO_LARGE_CODE`, named here so
126
+ * the lane module does not pull the packer onto the boot path). */
127
+ export const WRUN_OPTION_STRIKES_BLOCK_TOO_LARGE_CODE = 'wrun_cell_block_too_large';
128
+ /** The kit's code for a view word a host does not serve (`wrun_option_views_unserved`, kit 0.90.0). */
129
+ export const WRUN_OPTION_VIEWS_UNSERVED_REFUSAL = 'wrun_option_views_unserved';
130
+ /**
131
+ * Whether this host carries the strike kit fold's 14-value rows into a run. It does: every reader of the block sizes
132
+ * it by the input's own width (wrun-option-views.util `wrunOptionInputTupleWidth`, the SDK's one rule): the row lane's
133
+ * plan, the run's packer (wrun-pack.util `packWrunRows`) and, from kit 0.91.1, the shared host's aligner (kit
134
+ * `alignWrunRows`), which read the block in the class's 12-value tuples before. False refuses a kit fold input by name
135
+ * after its knobs pass, never read wrong.
136
+ */
137
+ export const WRUN_OPTION_STRIKES_KIT_SERVED = true;
138
+ /**
139
+ * The acquisition fields of an input's strike kit fold (OPTLOAD G5): the fold, its params and the input's `max_cells`,
140
+ * so the gateway (or the worker's fold while the gateway refuses it) answers a refused levels row for a bar whose newest
141
+ * minute held more rows. The fold reads every expiry of the minute (its `nearest` keeps the soonest): an `expiries`
142
+ * word other than "all" beside it was refused at declaration (`wrunOptionLaneAskOfSource`, the SDK's words).
143
+ */
144
+ export function wrunOptionStrikesKitExtras(ask, ctx) {
145
+ return wrunOptionLaneAskFields(ask, { maxCells: ctx.maxCells });
146
+ }
147
+ /** Whether a kit fold bar's rows carry the refusal: its levels row with `refused` 1 (the bar's newest minute held more
148
+ * rows than the input's `max_cells`). */
149
+ export function wrunOptionStrikesKitRefused(tuples) {
150
+ return tuples.some((tuple) => tuple[0] === WRUN_OPTION_STRIKES_KIT_LAYOUTS.levels && tuple[WRUN_OPTION_STRIKES_KIT_REFUSED_COLUMN] === 1);
151
+ }
152
+ /**
153
+ * One input's block on one bar: under fold "kit" the bar's kit rows as they are, a refused levels row refusing the run
154
+ * (`wrun_cell_block_too_large`, the block never truncated) or, for an input declaring `missing: "empty"`, reading that
155
+ * bar as a present empty block (C1.2b); else the tuples its `expiries` word keeps (`wrunOptionStrikesKept`).
156
+ */
157
+ export function wrunOptionStrikesCells(tuples, input) {
158
+ const source = input.source;
159
+ if (source.fold !== 'kit')
160
+ return wrunOptionStrikesKept(tuples, source.expiries);
161
+ if (!wrunOptionStrikesKitRefused(tuples))
162
+ return tuples;
163
+ if (input.source.missing === 'empty')
164
+ return [];
165
+ throw new Error(`${WRUN_OPTION_STRIKES_BLOCK_TOO_LARGE_CODE}: input '${input.name}' (option_strikes, fold "kit") read a bar whose ` +
166
+ `newest minute held more strike rows than its max_cells (${input.maxCells ?? 'unset'}), so the evaluation is ` +
167
+ 'refused (a block is never truncated)');
168
+ }
110
169
  export const rowLane = {
111
170
  sourceClass: 'option_strikes',
112
171
  laneKey: 'option_strikes',
@@ -123,7 +182,9 @@ export const rowLane = {
123
182
  horizon: wrunOptionStrikesHorizon,
124
183
  acquisitionMoved: wrunOptionStrikesAcquisitionMoved,
125
184
  identity: async (ctx) => {
126
- rememberStrikesChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx));
185
+ // O1: on the OPRA plane the chain is the plane's own by coin, no chain directory read.
186
+ const held = await wrunHeldOpraPlaneChain(ctx.exchange, ctx.coin, ctx.opraPlane);
187
+ rememberStrikesChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx, held));
127
188
  },
128
189
  facets: async (source, ctx) => {
129
190
  for (const knob of ['history', 'min_size']) {
@@ -149,6 +210,13 @@ export const rowLane = {
149
210
  }
150
211
  if (!decision.ok)
151
212
  throw wrunLaneChainRefusalError(decision, 'option_strikes');
213
+ // The kit fold and its params, by the SDK's rules (`wrun_option_knob_invalid`), then this host's guard.
214
+ const kit = wrunOptionLaneAskOfSource(source, ctx);
215
+ const kitExtras = kit === undefined ? undefined : wrunOptionStrikesKitExtras(kit, ctx);
216
+ if (kitExtras !== undefined && !WRUN_OPTION_STRIKES_KIT_SERVED) {
217
+ return refuseWrunPollInput(ctx, `reads option_strikes with fold "kit" (${WRUN_OPTION_VIEWS_UNSERVED_REFUSAL}): this app does not carry the ` +
218
+ "kit fold's rows into a run yet; read the strike rows whole (drop fold and its params)", wrunAuthorRuleSeed(WRUN_OPTION_VIEWS_UNSERVED_REFUSAL));
219
+ }
152
220
  const chain = await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx);
153
221
  return {
154
222
  // The chain's identity as the options chain keys it (one chain per package: `acquisitions: 'one'`).
@@ -156,7 +224,8 @@ export const rowLane = {
156
224
  ...wrunOptionStrikesExtras(chain),
157
225
  // The run's bar span: the worker keeps the newest minute of each of these bars.
158
226
  hostIntervalMs: ctx.intervalMs,
227
+ ...kitExtras,
159
228
  };
160
229
  },
161
- cells: (tuples, input) => wrunOptionStrikesKept(tuples, input.source.expiries),
230
+ cells: wrunOptionStrikesCells,
162
231
  };
@@ -27,11 +27,21 @@
27
27
  * decided when the run plans and named in the acquisition, `auto` the chain's default book over the series its
28
28
  * directory lists, opra-option-lanes.util `resolveWrunLaneChainAutoBook`; an answer never picks it) and `max_cells`
29
29
  * (a block over it refuses the run); a market pin and the other options classes' knobs refuse by name.
30
+ * - `pick` (OPTLOAD G5, kit 0.90.0; wrun-option-views.util): "nearest_days" (`days`, `delta`) or "tenor_bracket"
31
+ * (`tenor`), each param a number (a setting's value once the paint seam wrote it), refused by the SDK's rules by
32
+ * name (`wrun_option_knob_invalid`). Each bar's block is the pick of its landed bucket (`wrunOptionSurfacePickTuples`,
33
+ * the SDK's reference), so the template reads the one or two tuples it reads today. The pick's fields ride the
34
+ * acquisition (`surfacePick` and its params, with the run's bar span), so the worker asks OPTION_SURFACE grouped to
35
+ * the chart's bars with the pick applied there (`optionRead`: the gateway lands each bar on its newest sealed 5m
36
+ * bucket, as this lane lands it) and reads today's buckets while the gateway refuses the read; the pick applied on
37
+ * the page to a bar the gateway picked picks the same tuples. An input without `pick` asks and lands as before.
38
+ * - O1 (OPTLOAD G5): on the OPRA plane the chain is the plane's own by coin (`wrunHeldOpraPlaneChain`), no chain
39
+ * directory read.
30
40
  *
31
41
  * LIGHT at module load: pb-common and the chain resolver are imported inside `identity`.
32
42
  */
33
43
  import { type WrunLaneChain } from '../opra-option-lanes.util.js';
34
- import type { WrunRowLaneDescriptor } from '../wrun-row-lane.types.js';
44
+ import type { WrunRowLaneCellInput, WrunRowLaneDescriptor } from '../wrun-row-lane.types.js';
35
45
  import type { WrunBackendTier } from '../../wrun-tier-grid.util.js';
36
46
  /** f64s per tuple (the source contract's width, the `present` mask included). */
37
47
  export declare const WRUN_OPTION_SURFACE_WIDTH = 9;
@@ -67,4 +77,7 @@ export declare function wrunOptionSurfaceAcquisitionMoved(acquisition: Readonly<
67
77
  * bar reads its settlement instead of nothing. An OPRA or crypto chain keeps the tier rule as it is.
68
78
  */
69
79
  export declare function wrunOptionSurfaceReadsSettlements(acquisition: Readonly<Record<string, unknown>>): boolean;
80
+ /** One input's block on one bar: the pick of the bar's tuples when the input declares `pick` (the SDK's reference,
81
+ * idempotent on a bar the gateway picked), else the tuples as they are. */
82
+ export declare function wrunOptionSurfaceCells(tuples: ReadonlyArray<ReadonlyArray<number>>, input: Pick<WrunRowLaneCellInput, 'source'>): ReadonlyArray<ReadonlyArray<number>>;
70
83
  export declare const rowLane: WrunRowLaneDescriptor;
@@ -27,11 +27,22 @@
27
27
  * decided when the run plans and named in the acquisition, `auto` the chain's default book over the series its
28
28
  * directory lists, opra-option-lanes.util `resolveWrunLaneChainAutoBook`; an answer never picks it) and `max_cells`
29
29
  * (a block over it refuses the run); a market pin and the other options classes' knobs refuse by name.
30
+ * - `pick` (OPTLOAD G5, kit 0.90.0; wrun-option-views.util): "nearest_days" (`days`, `delta`) or "tenor_bracket"
31
+ * (`tenor`), each param a number (a setting's value once the paint seam wrote it), refused by the SDK's rules by
32
+ * name (`wrun_option_knob_invalid`). Each bar's block is the pick of its landed bucket (`wrunOptionSurfacePickTuples`,
33
+ * the SDK's reference), so the template reads the one or two tuples it reads today. The pick's fields ride the
34
+ * acquisition (`surfacePick` and its params, with the run's bar span), so the worker asks OPTION_SURFACE grouped to
35
+ * the chart's bars with the pick applied there (`optionRead`: the gateway lands each bar on its newest sealed 5m
36
+ * bucket, as this lane lands it) and reads today's buckets while the gateway refuses the read; the pick applied on
37
+ * the page to a bar the gateway picked picks the same tuples. An input without `pick` asks and lands as before.
38
+ * - O1 (OPTLOAD G5): on the OPRA plane the chain is the plane's own by coin (`wrunHeldOpraPlaneChain`), no chain
39
+ * directory read.
30
40
  *
31
41
  * LIGHT at module load: pb-common and the chain resolver are imported inside `identity`.
32
42
  */
33
43
  import { decideWrunLaneChain, refuseWrunLaneStrayKnob, resolveWrunLaneChainChart, WRUN_OPTION_CHART_UNRESOLVED_CODE, wrunLaneChainLeadMoved, wrunLaneChainPlaneOf, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
34
44
  import { refuseWrunPollInput } from '../wrun-poll-lane.types.js';
45
+ import { wrunHeldOpraPlaneChain, wrunOptionLaneAskFields, wrunOptionLaneAskOf, wrunOptionLaneAskOfSource, wrunOptionSurfacePickTuples, } from '../../wrun-option-views.util.js';
35
46
  import { assertWrunProtocolType } from '../../wrun-protocol-pending.util.js';
36
47
  import { wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
37
48
  const MINUTE_MS = 60_000;
@@ -113,6 +124,14 @@ export function wrunOptionSurfaceReadsSettlements(acquisition) {
113
124
  const exchange = acquisition[WRUN_OPTION_SURFACE_EXCHANGE_FIELD];
114
125
  return wrunLaneChainPlaneOf(typeof exchange === 'string' ? exchange : '') === 'cme';
115
126
  }
127
+ /** One input's block on one bar: the pick of the bar's tuples when the input declares `pick` (the SDK's reference,
128
+ * idempotent on a bar the gateway picked), else the tuples as they are. */
129
+ export function wrunOptionSurfaceCells(tuples, input) {
130
+ const read = wrunOptionLaneAskOf(input.source);
131
+ return read !== undefined && 'ask' in read
132
+ ? wrunOptionSurfacePickTuples(tuples, read.ask.word, read.ask.params)
133
+ : tuples;
134
+ }
116
135
  export const rowLane = {
117
136
  sourceClass: 'option_surface',
118
137
  laneKey: 'option_surface',
@@ -125,7 +144,9 @@ export const rowLane = {
125
144
  acquisitionMoved: wrunOptionSurfaceAcquisitionMoved,
126
145
  identity: async (ctx) => {
127
146
  await assertWrunProtocolType(ctx, WRUN_OPTION_SURFACE_TYPE, 'option_surface');
128
- rememberSurfaceChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx));
147
+ // O1: on the OPRA plane the chain is the plane's own by coin, no chain directory read.
148
+ const held = await wrunHeldOpraPlaneChain(ctx.exchange, ctx.coin, ctx.opraPlane);
149
+ rememberSurfaceChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx, held));
129
150
  },
130
151
  facets: async (source, ctx) => {
131
152
  for (const [knob, owners] of STRAY_KNOBS) {
@@ -135,10 +156,17 @@ export const rowLane = {
135
156
  if (source.symbol !== undefined || source.exchange !== undefined) {
136
157
  refuseWrunPollInput(ctx, "pins option_surface cells to a fixed market (wrun_option_market_pinned); it reads the chart's own underlying, so drop the symbol and exchange pin", wrunAuthorRuleSeed('wrun_option_market_pinned'));
137
158
  }
159
+ // The pick and its params, by the SDK's rules, before any chain read.
160
+ const pick = wrunOptionLaneAskOfSource(source, ctx);
138
161
  const chart = surfaceCharts.get(wrunLaneChartKey(ctx));
139
162
  if (chart === undefined) {
140
163
  return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', wrunAuthorRuleSeed(WRUN_OPTION_CHART_UNRESOLVED_CODE));
141
164
  }
142
- return wrunOptionSurfaceExtras(await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx));
165
+ const extras = wrunOptionSurfaceExtras(await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx));
166
+ // A pick asks the gateway to land and pick each of the run's bars: its fields and the run's bar span.
167
+ return pick === undefined
168
+ ? extras
169
+ : { ...extras, ...wrunOptionLaneAskFields(pick), hostIntervalMs: ctx.intervalMs };
143
170
  },
171
+ cells: wrunOptionSurfaceCells,
144
172
  };
@@ -41,7 +41,7 @@
41
41
  import type { WrunInputSource } from '../../../interfaces/wrun-runtime.interface.js';
42
42
  import type { WrunDailyLanding } from '../wrun-daily-lane.util.js';
43
43
  import { type WrunRefusalSeed } from '../wrun-refusal.util.js';
44
- import type { WrunBackendTier, WrunTierLanding } from '../wrun-tier-grid.util.js';
44
+ import type { WrunBackendTier, WrunTierChoice, WrunTierLanding } from '../wrun-tier-grid.util.js';
45
45
  import type { WrunRowLaneChain, WrunRowLaneHorizon } from './wrun-row-lane.types.js';
46
46
  /** An input's declaration as a lane reads it: the typed fields, and any knob the sheet carries
47
47
  * that the interface does not name yet (`asset`, `publisher`, `series`, ...), as `unknown`. */
@@ -115,10 +115,16 @@ export type WrunPollLaneJoin = 'bar' | {
115
115
  * the asks under the tier rule: each bar is read from the finest tier that fits it and still retains it, one
116
116
  * ask per run of bars on a tier, the tier's key in the ask's payload (`tier`); a bar no tier retains reads
117
117
  * no row (the input's `missing` policy). Absent: one ask, the rows as the control answers them.
118
+ * `tierChoice: 'coarsest'` (a flow with tiers only) reads each bar from the coarsest fitting tier that retains it and
119
+ * already serves it (each tier's `servedLagMs`: a bar that closed inside a coarser tier's lag, the forming one among
120
+ * them, reads the next finer tier) instead of the finest: for a lane whose landing sums the same per-bar values from
121
+ * any tier, so a coarse bar reads fewer buckets (the row lanes' rule, wrun-tier-grid.util `wrunBarTiers`). Absent: the
122
+ * finest (rule 9), as every lane that names none.
118
123
  */
119
124
  export interface WrunPollLaneBarGrid {
120
125
  landing: WrunTierLanding;
121
126
  tiers?: readonly WrunBackendTier[];
127
+ tierChoice?: WrunTierChoice;
122
128
  }
123
129
  /** What `plan` returns: the payload fields beyond the current-market placeholders (`symbol:
124
130
  * 'currentSymbol'`, `exchange: 'currentExchange'`), or nothing when the placeholders are the
@@ -34,13 +34,16 @@
34
34
  * OPRA plane facts (`wrunChartOpraPlane`), a chain lane's OPRA wall and stop before its chain is resolved
35
35
  * (`wrunChainLaneStop`), a lane's refusal that the chart has no option chain (`wrunLaneNoChainRefusal`), and what an
36
36
  * input the chart does not serve does (`wrunUnservedLaneInput`: a declared fill drops it with a note, any other
37
- * refuses by name).
37
+ * refuses by name); an option knob naming a setting read as its current value (`resolveWrunOptionSettingKnobs`, over
38
+ * the one table `WRUN_OPTION_SETTING_KNOBS`, every kind of knob the kit binds: no lane reads a setting itself).
39
+ * - a host-grid lane's asks (`fetchWrunPollLaneHostGridRows`): its tier rule, the finest fitting tier or, for a lane
40
+ * naming `tierChoice: 'coarsest'`, the coarsest that already serves the bar.
38
41
  */
39
- import type { WrunIndicatorMetadata, WrunInputSource } from '../../../interfaces/wrun-runtime.interface.js';
42
+ import type { WrunIndicatorMetadata, WrunInputSource, WrunMetadataParam } from '../../../interfaces/wrun-runtime.interface.js';
40
43
  import type { OpraReadFacts } from '../../chart/opra-read-access.leaf.js';
41
44
  import type { OpraOptionPlaneStop } from '../../../host-ports.types.js';
42
45
  import { type WrunRefusalSeed } from '../wrun-refusal.util.js';
43
- import { type WrunPollLane, type WrunPollLaneContext, type WrunPollLaneId, type WrunPollLaneInstance } from './wrun-poll-lane.types.js';
46
+ import { type WrunPollLane, type WrunPollLaneContext, type WrunPollLaneId, type WrunPollLaneInstance, type WrunPollLaneSource } from './wrun-poll-lane.types.js';
44
47
  import { type WrunLaneChainPlane, type WrunRowLaneHorizon } from './wrun-row-lane.types.js';
45
48
  import type { WrunMissingFeed } from '../wrun-run-health.util.js';
46
49
  import type { LiveBucketVenue } from '../../chart/live-bucket.util.js';
@@ -82,7 +85,38 @@ export interface WrunPollLaneRunFacts extends OpraReadFacts {
82
85
  * `opraOptionPlaneStop`: the flag check's `flag-off`, the plane router's `chart-kind`); absent, the market's own
83
86
  * words ("no such feed here"). */
84
87
  opraPlaneStop?: (exchange: string) => OpraOptionPlaneStop | undefined;
88
+ /** The run's current setting values by name (wrun-param-values.util `wrunParamValuesFromSettings` over the
89
+ * overlay's settings): what an option knob naming a setting reads (`resolveWrunOptionSettingKnobs`). Absent, no
90
+ * knob's setting is read, and a lane refuses a name it cannot read by name. */
91
+ paramValues?: Readonly<Record<string, number>>;
85
92
  }
93
+ /**
94
+ * The kind of value a setting-bound option knob takes (om kit `WrunOptionParamKnobKind`): `number` a number, int or
95
+ * price setting's number; `word` the label of a select's picked option, one of the knob's words; `list` the labels of a
96
+ * multi's picked options, each one of the knob's words, in the words' order.
97
+ */
98
+ export type WrunOptionSettingKnobKind = 'number' | 'word' | 'list';
99
+ /**
100
+ * The option knobs a setting may stand for, by source class, with the kind each takes (om kit 0.89.0
101
+ * `WRUN_OPTION_PARAM_KNOBS`, row for row): ONE table for both planners, read before a poll lane's `plan` and a row lane's
102
+ * `facets` (`resolveWrunOptionSettingKnobs`), so no lane reads a setting itself. The sheet records the setting's NAME in
103
+ * the knob (an author's `min_premium: "@floor"` compiles to `"floor"`), and every host reads that setting's current
104
+ * value on each run, so a settings change re-plans the input and its ask carries the new value: no rebuild.
105
+ * tests/utility/wrun/sources/wrun-row-lanes.setting-knobs.spec.ts holds every row of a class the browser serves equal to
106
+ * the kit's.
107
+ */
108
+ export declare const WRUN_OPTION_SETTING_KNOBS: Readonly<Record<string, Readonly<Record<string, WrunOptionSettingKnobKind>>>>;
109
+ /**
110
+ * One input's source with every option knob that names a setting read as the setting's current value (om
111
+ * `resolveOptionParamKnobs`, the SDK host's rule, over the class's row of `WRUN_OPTION_SETTING_KNOBS`): a number knob
112
+ * takes a number, int or price setting's number; a word knob (`types`, `moneyness`) the label of a select's picked
113
+ * option, one of its words; a list knob (`sides`) the labels of a multi's picked options, in the words' order. The name
114
+ * must be a compute setting of the sheet (a style knob is none) with a value this run read, of the knob's kind and
115
+ * picking its words, else the input is refused by name (`wrun_option_knob_invalid`). A literal (a number, a list, a word
116
+ * of the knob's own) is left as it is (its lane judges it), and so is every input when the run read no setting values; a
117
+ * class with no such knob is its own source, untouched, so every other lane plans exactly as before.
118
+ */
119
+ export declare function resolveWrunOptionSettingKnobs(ctx: Pick<WrunPollLaneContext, 'inputName' | 'sourceClass'>, source: WrunPollLaneSource, params: readonly WrunMetadataParam[], values: Readonly<Record<string, number>> | undefined): WrunPollLaneSource;
86
120
  /** The technical words of an OPRA lane a known stop keeps off the chart (Copy details), by the stop's reason. */
87
121
  export declare function wrunOpraPlaneStopDetail(stop: OpraOptionPlaneStop): string;
88
122
  /** The chart's OPRA plane facts as both planners read them, once per plan (`wrunChartOpraPlane`). */
@@ -233,6 +267,10 @@ export type WrunPollLanePlanResult = WrunPollLanePlan & WrunPollLaneInstance[];
233
267
  * nowhere, before all of the above: no wall, no admission, no `plan`, no fetch, no note; the row builder reads its
234
268
  * fill on every bar.
235
269
  *
270
+ * An option knob naming a setting (`min_premium: "floor"`, an author's `"@floor"`) reads the setting's current value
271
+ * (`run.paramValues`) before the lane's `plan` judges it (`resolveWrunOptionSettingKnobs`, the SDK host's rule): the
272
+ * instance's extras carry the value, so a settings change re-plans the input and re-asks with it.
273
+ *
236
274
  * The predicates are injected (the run pass hands the chart's own `checkIsIndexMode` and its
237
275
  * crypto-venue rule), so this module, which the row builder imports, stays off those modules'
238
276
  * import graphs; without one no chart reads as index-mode, and without the other the venue is
@@ -370,8 +408,10 @@ export declare function wrunHostGridAsksWithinHorizon(plan: {
370
408
  /**
371
409
  * A lane's rows over a chart window, landed on the host bars when it is a host-grid lane (`barGrid`): its asks
372
410
  * under the tier rule (`wrunHostGridAsks` over the window's host bars: one per run of bars on a tier, the
373
- * tier's key in its extras as `tier`), cut to the lane's `horizon` for the acquisition (`wrunHostGridAsksWithinHorizon`:
374
- * the bars its source no longer holds ask nothing and read the input's `missing` policy), each answer landed by the
411
+ * tier's key in its extras as `tier`; each bar's tier the finest fitting one that retains it, or the coarsest that
412
+ * already serves it for a lane naming `tierChoice: 'coarsest'`), cut to the lane's `horizon` for the acquisition
413
+ * (`wrunHostGridAsksWithinHorizon`: the bars its source no longer holds ask nothing and read the input's `missing`
414
+ * policy), each answer landed by the
375
415
  * lane's landing (`wrunLandScalarRowsOnHostBars`: a flow summed per bar, a snapshot's newest sealed row, sealed by its
376
416
  * ask's tier), ascending. A bar no tier retains asks nothing and reads no row. A flow sums every bucket inside its bar,
377
417
  * so its plan reads the window's bar grid as its session grid (wrun-tier-grid.util `wrunCmeSessionBarSpan`): a CME
@@ -1,3 +1,7 @@
1
+ import { wrunParamChoices } from '../wrun-color-settings.util.js';
2
+ import { refuseWrunOptionKnob } from '../wrun-option-knobs.util.js';
3
+ import { wrunOptionPrintKnobWords } from '../wrun-option-prints.util.js';
4
+ import { wrunMultiLabels } from '../wrun-param-values.util.js';
1
5
  import { wrunOptionsStopSeed, wrunRefusalSeedOf } from '../wrun-refusal.util.js';
2
6
  import { wrunPollLaneByKey, wrunPollLaneGlobalClasses, wrunPollLanes, wrunPollLanesOfClass } from './registry.js';
3
7
  import { refuseWrunPollInput, WRUN_POLL_LANE_ID_PREFIX, } from './wrun-poll-lane.types.js';
@@ -85,6 +89,104 @@ function wrunPollLaneNativeRowsClasses() {
85
89
  function wrunPollLaneServedOnIndexMode(lane) {
86
90
  return lane.global === true || lane.nativeRows === true;
87
91
  }
92
+ /**
93
+ * The option knobs a setting may stand for, by source class, with the kind each takes (om kit 0.89.0
94
+ * `WRUN_OPTION_PARAM_KNOBS`, row for row): ONE table for both planners, read before a poll lane's `plan` and a row lane's
95
+ * `facets` (`resolveWrunOptionSettingKnobs`), so no lane reads a setting itself. The sheet records the setting's NAME in
96
+ * the knob (an author's `min_premium: "@floor"` compiles to `"floor"`), and every host reads that setting's current
97
+ * value on each run, so a settings change re-plans the input and its ask carries the new value: no rebuild.
98
+ * tests/utility/wrun/sources/wrun-row-lanes.setting-knobs.spec.ts holds every row of a class the browser serves equal to
99
+ * the kit's.
100
+ */
101
+ export const WRUN_OPTION_SETTING_KNOBS = Object.freeze({
102
+ options_flow: Object.freeze({ min_premium: 'number', max_dte: 'number' }),
103
+ option_contract_flow: Object.freeze({ min_premium: 'number' }),
104
+ option_strike_flow: Object.freeze({ strike_rows: 'number' }),
105
+ option_prints: Object.freeze({
106
+ min_premium: 'number',
107
+ types: 'word',
108
+ sides: 'list',
109
+ moneyness: 'word',
110
+ max_dte: 'number',
111
+ newest_tail_ms: 'number',
112
+ }),
113
+ });
114
+ /** The setting types a number knob reads (om `resolveOptionParamKnobs`: a number, int or price setting). */
115
+ const WRUN_NUMBER_SETTING_TYPES = new Set(['number', 'int', 'price']);
116
+ /** What a knob of each kind takes beside a setting's name, as its refusal spells it. */
117
+ function wrunSettingKnobLiteralWords(kind, words) {
118
+ if (kind === 'number')
119
+ return 'a number';
120
+ return kind === 'word' ? `one of ${words.join(', ')}` : `a list of ${words.join(', ')}`;
121
+ }
122
+ /** The setting a knob of each kind reads its value from, as its refusal spells it. */
123
+ const WRUN_SETTING_KNOB_SETTINGS = Object.freeze({
124
+ number: 'a number, int or price setting',
125
+ word: 'a select setting whose picked option is labelled with one of them',
126
+ list: 'a multi setting whose picked options are labelled with them',
127
+ });
128
+ /** The literal a setting stands for on a knob of `kind` at the run's `value`, or why it stands for none. */
129
+ function wrunSettingKnobLiteral(kind, words, param, value) {
130
+ const type = param.type ?? 'number';
131
+ if (kind === 'number')
132
+ return WRUN_NUMBER_SETTING_TYPES.has(type) ? { literal: value } : { why: `is a ${type} setting` };
133
+ if (kind === 'word') {
134
+ if (type !== 'select')
135
+ return { why: `is a ${type} setting` };
136
+ // THE select read's choices (a select's options, labelled by `option_labels`), the picked one by its value.
137
+ const label = wrunParamChoices(param)?.find((choice) => choice.value === value)?.label;
138
+ return label !== undefined && words.includes(label) ? { literal: label } : { why: `picks '${label ?? value}'` };
139
+ }
140
+ if (type !== 'multi')
141
+ return { why: `is a ${type} setting` };
142
+ if (!Number.isInteger(value) || value < 0)
143
+ return { why: `picks ${value}` };
144
+ const picked = wrunMultiLabels(param).filter((_, bit) => Math.floor(value / 2 ** bit) % 2 === 1);
145
+ if (!picked.every((label) => words.includes(label))) {
146
+ return { why: `picks ${picked.map((label) => `'${label}'`).join(', ')}` };
147
+ }
148
+ return { literal: words.filter((word) => picked.includes(word)) };
149
+ }
150
+ /**
151
+ * One input's source with every option knob that names a setting read as the setting's current value (om
152
+ * `resolveOptionParamKnobs`, the SDK host's rule, over the class's row of `WRUN_OPTION_SETTING_KNOBS`): a number knob
153
+ * takes a number, int or price setting's number; a word knob (`types`, `moneyness`) the label of a select's picked
154
+ * option, one of its words; a list knob (`sides`) the labels of a multi's picked options, in the words' order. The name
155
+ * must be a compute setting of the sheet (a style knob is none) with a value this run read, of the knob's kind and
156
+ * picking its words, else the input is refused by name (`wrun_option_knob_invalid`). A literal (a number, a list, a word
157
+ * of the knob's own) is left as it is (its lane judges it), and so is every input when the run read no setting values; a
158
+ * class with no such knob is its own source, untouched, so every other lane plans exactly as before.
159
+ */
160
+ export function resolveWrunOptionSettingKnobs(ctx, source, params, values) {
161
+ const knobs = Object.prototype.hasOwnProperty.call(WRUN_OPTION_SETTING_KNOBS, ctx.sourceClass)
162
+ ? WRUN_OPTION_SETTING_KNOBS[ctx.sourceClass]
163
+ : undefined;
164
+ if (knobs === undefined || values === undefined)
165
+ return source;
166
+ let resolved;
167
+ for (const [knob, kind] of Object.entries(knobs)) {
168
+ const name = source[knob];
169
+ if (typeof name !== 'string')
170
+ continue;
171
+ const words = wrunOptionPrintKnobWords(knob);
172
+ // A word knob's own word is a literal, never a setting's name.
173
+ if (kind === 'word' && words.includes(name))
174
+ continue;
175
+ const literalWords = wrunSettingKnobLiteralWords(kind, words);
176
+ const param = params.find((candidate) => candidate.name === name);
177
+ const value = Object.prototype.hasOwnProperty.call(values, name) ? values[name] : undefined;
178
+ if (param === undefined || param.style !== undefined || typeof value !== 'number' || !Number.isFinite(value)) {
179
+ return refuseWrunOptionKnob(ctx, knob, name, `${literalWords} or the name of a compute setting of the sheet, and '${name}' is no such setting`);
180
+ }
181
+ const read = wrunSettingKnobLiteral(kind, words, param, value);
182
+ if ('why' in read) {
183
+ return refuseWrunOptionKnob(ctx, knob, name, `${literalWords} or the name of ${WRUN_SETTING_KNOB_SETTINGS[kind]}, and '${name}' ${read.why}`);
184
+ }
185
+ resolved ??= { ...source };
186
+ resolved[knob] = read.literal;
187
+ }
188
+ return resolved === undefined ? source : resolved;
189
+ }
88
190
  /** Why an `opra` lane is not served on a chart whose options ride no OPRA plane, as its refusal says it. */
89
191
  const WRUN_POLL_OPRA_UNADMITTED_REASON = "is not served on this chart: it reads US options data, which a US stock or ETF chart (its underlying's options) and an OPRA option contract chart serve";
90
192
  /** The technical words of an OPRA lane a known stop keeps off the chart (Copy details), by the stop's reason. */
@@ -277,6 +379,10 @@ function wrunPollLanePlanResult(lanes, missingFeeds) {
277
379
  * nowhere, before all of the above: no wall, no admission, no `plan`, no fetch, no note; the row builder reads its
278
380
  * fill on every bar.
279
381
  *
382
+ * An option knob naming a setting (`min_premium: "floor"`, an author's `"@floor"`) reads the setting's current value
383
+ * (`run.paramValues`) before the lane's `plan` judges it (`resolveWrunOptionSettingKnobs`, the SDK host's rule): the
384
+ * instance's extras carry the value, so a settings change re-plans the input and re-asks with it.
385
+ *
280
386
  * The predicates are injected (the run pass hands the chart's own `checkIsIndexMode` and its
281
387
  * crypto-venue rule), so this module, which the row builder imports, stays off those modules'
282
388
  * import graphs; without one no chart reads as index-mode, and without the other the venue is
@@ -335,7 +441,10 @@ export async function planWrunPollLanes(metadata, chart, isIndexModeExchange = (
335
441
  }
336
442
  let answered;
337
443
  try {
338
- answered = await planned.lane.plan(planned.source, ctx);
444
+ // An option knob naming a setting reads the setting's current value before the lane judges it (om
445
+ // `resolveOptionParamKnobs`): the instance's extras carry the value, so a settings change re-plans and re-asks.
446
+ const source = resolveWrunOptionSettingKnobs(ctx, planned.source, metadata.params ?? [], run?.paramValues);
447
+ answered = await planned.lane.plan(source, ctx);
339
448
  }
340
449
  catch (error) {
341
450
  // A chart with no option chain does not serve the feed (`wrunLaneNoChainRefusal`), nor one whose options plane
@@ -602,8 +711,10 @@ export function wrunHostGridAsksWithinHorizon(plan, window, horizon, sessionGrid
602
711
  /**
603
712
  * A lane's rows over a chart window, landed on the host bars when it is a host-grid lane (`barGrid`): its asks
604
713
  * under the tier rule (`wrunHostGridAsks` over the window's host bars: one per run of bars on a tier, the
605
- * tier's key in its extras as `tier`), cut to the lane's `horizon` for the acquisition (`wrunHostGridAsksWithinHorizon`:
606
- * the bars its source no longer holds ask nothing and read the input's `missing` policy), each answer landed by the
714
+ * tier's key in its extras as `tier`; each bar's tier the finest fitting one that retains it, or the coarsest that
715
+ * already serves it for a lane naming `tierChoice: 'coarsest'`), cut to the lane's `horizon` for the acquisition
716
+ * (`wrunHostGridAsksWithinHorizon`: the bars its source no longer holds ask nothing and read the input's `missing`
717
+ * policy), each answer landed by the
607
718
  * lane's landing (`wrunLandScalarRowsOnHostBars`: a flow summed per bar, a snapshot's newest sealed row, sealed by its
608
719
  * ask's tier), ascending. A bar no tier retains asks nothing and reads no row. A flow sums every bucket inside its bar,
609
720
  * so its plan reads the window's bar grid as its session grid (wrun-tier-grid.util `wrunCmeSessionBarSpan`): a CME
@@ -621,6 +732,7 @@ export async function fetchWrunPollLaneHostGridRows(lane, extras, window, fallba
621
732
  barOpens: window.barOpens,
622
733
  intervalMs: window.intervalMs,
623
734
  nowMs: window.nowMs,
735
+ ...(grid.tierChoice !== undefined ? { choice: grid.tierChoice } : {}),
624
736
  ...(sessionGrid !== undefined ? { sessionGrid } : {}),
625
737
  }), window, lane.horizon?.(extras, window.nowMs), sessionGrid);
626
738
  const answers = await Promise.all(asks.map(async (gridAsk) => {
@@ -0,0 +1,10 @@
1
+ import type { LiveBucketVenue } from '../../chart/live-bucket.util.js';
2
+ import type { WrunRowLaneRowBudget } from './wrun-row-lane.types.js';
3
+ import type { WrunRowLaneWindow } from './wrun-row-lanes.util.js';
4
+ import { type WrunHostGridAsk } from '../wrun-tier-grid.util.js';
5
+ /** The most host bars a row lane's first ask covers (OPTLOAD first paint: the newest 30 bars first). */
6
+ export declare const WRUN_ROW_LANE_FIRST_PAINT_BARS = 30;
7
+ /** The most bytes a row lane's first ask is projected to answer (OPTLOAD first paint: 0.25 MB, at 8 bytes a cell). */
8
+ export declare const WRUN_ROW_LANE_FIRST_PAINT_BYTES: number;
9
+ /** A host-grid ask plan ordered for first paint (see the module doc). */
10
+ export declare function wrunRowLaneFirstPaintAsks(asks: readonly WrunHostGridAsk[], window: Pick<WrunRowLaneWindow, 'barOpens' | 'intervalMs' | 'nowMs'>, budget: WrunRowLaneRowBudget | undefined, acquisition?: Readonly<Record<string, unknown>>, sessionGrid?: LiveBucketVenue | null): WrunHostGridAsk[];
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The first-paint slice of a row lane with a row budget (OPTLOAD-READ-CONTRACT FE-STRIKE-LANE; the per-strike and
3
+ * per-contract flow lanes): the NEWEST asked bars, at most `WRUN_ROW_LANE_FIRST_PAINT_BARS` and only as many as the
4
+ * lane's projection (`barRows` x `cellsPerRow` x 8 bytes) fits `WRUN_ROW_LANE_FIRST_PAINT_BYTES` (the newest bar at
5
+ * least), are asked on their own and FIRST; the asks are cut at that slice's first bar (never inside a bar) and the older
6
+ * parts follow, newest first. The asks cover the same bars at the same tiers, so the landed rows are the same. A lane
7
+ * with no row budget, and a plan the slice holds whole, keep their plan. wrun-row-lanes.util `fetchWrunRowLaneRows`
8
+ * loads this module for a row-budget lane only, so it stays off the boot path (tests/utility/wrun/wrun-door.closure).
9
+ */
10
+ import { KSCRIPT_SOURCE_CELL_BYTES } from '../../chart/kscript-source-answer-budget.leaf.js';
11
+ import { wrunHostBarSpanOf } from '../wrun-tier-grid.util.js';
12
+ /** The most host bars a row lane's first ask covers (OPTLOAD first paint: the newest 30 bars first). */
13
+ export const WRUN_ROW_LANE_FIRST_PAINT_BARS = 30;
14
+ /** The most bytes a row lane's first ask is projected to answer (OPTLOAD first paint: 0.25 MB, at 8 bytes a cell). */
15
+ export const WRUN_ROW_LANE_FIRST_PAINT_BYTES = 256 * 1024;
16
+ /** A host-grid ask plan ordered for first paint (see the module doc). */
17
+ export function wrunRowLaneFirstPaintAsks(asks, window, budget, acquisition = {}, sessionGrid) {
18
+ if (budget === undefined || asks.length === 0)
19
+ return [...asks];
20
+ const asked = [];
21
+ for (const ask of asks) {
22
+ for (const stampMs of window.barOpens) {
23
+ const span = wrunHostBarSpanOf(stampMs, window.intervalMs, sessionGrid);
24
+ if (span.fromMs < ask.fromMs || span.fromMs >= ask.toMs)
25
+ continue;
26
+ asked.push({ fromMs: span.fromMs, toMs: span.toMs, tier: ask.tier });
27
+ }
28
+ }
29
+ asked.sort((a, b) => b.fromMs - a.fromMs);
30
+ let bytes = 0;
31
+ let sliceFrom = Number.POSITIVE_INFINITY;
32
+ for (let at = 0; at < asked.length && at < WRUN_ROW_LANE_FIRST_PAINT_BARS; at += 1) {
33
+ const bar = asked[at];
34
+ const projected = budget.barRows({ openMs: bar.fromMs, endMs: bar.toMs, tier: bar.tier }, window.nowMs, acquisition);
35
+ const barRows = Number.isFinite(projected) && projected > 0 ? projected : 0;
36
+ const barBytes = barRows * budget.cellsPerRow * KSCRIPT_SOURCE_CELL_BYTES;
37
+ if (at > 0 && bytes + barBytes > WRUN_ROW_LANE_FIRST_PAINT_BYTES)
38
+ break;
39
+ bytes += barBytes;
40
+ sliceFrom = bar.fromMs;
41
+ }
42
+ if (!Number.isFinite(sliceFrom) || asked.every((bar) => bar.fromMs >= sliceFrom))
43
+ return [...asks];
44
+ const first = [];
45
+ const older = [];
46
+ for (const ask of asks) {
47
+ if (ask.fromMs >= sliceFrom)
48
+ first.push(ask);
49
+ else if (ask.toMs <= sliceFrom)
50
+ older.push(ask);
51
+ else {
52
+ older.push({ ...ask, toMs: sliceFrom });
53
+ first.push({ ...ask, fromMs: sliceFrom });
54
+ }
55
+ }
56
+ return [...first, ...older.sort((a, b) => b.fromMs - a.fromMs)];
57
+ }