@orangecharts/wrun-chart-host 0.6.0 → 0.7.1

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 (142) hide show
  1. package/README.md +14 -5
  2. package/dist/constants/marketCapabilities.constants.d.ts +5 -0
  3. package/dist/constants/marketCapabilities.constants.js +16 -0
  4. package/dist/host-ports.types.d.ts +35 -3
  5. package/dist/index.d.ts +11 -1
  6. package/dist/index.js +11 -1
  7. package/dist/indicators/controls/tpo-session.util.js +42 -18
  8. package/dist/market-data/billing.interface.d.ts +2 -1
  9. package/dist/settings-templates/index.d.ts +2 -0
  10. package/dist/settings-templates/index.js +19 -5
  11. package/dist/settings-templates/indicator-fields.d.ts +2 -0
  12. package/dist/settings-templates/indicator-fields.js +10 -0
  13. package/dist/settings-templates/tool-rules.d.ts +12 -2
  14. package/dist/settings-templates/tool-rules.js +9 -2
  15. package/dist/settings-templates/tool-tables.generated.js +9 -0
  16. package/dist/utility/chart/crypto-index.leaf.d.ts +16 -0
  17. package/dist/utility/chart/crypto-index.leaf.js +19 -0
  18. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  19. package/dist/utility/chart/index-mode.util.d.ts +11 -5
  20. package/dist/utility/chart/index-mode.util.js +22 -10
  21. package/dist/utility/chart/kscript-source-answer-budget.leaf.d.ts +36 -0
  22. package/dist/utility/chart/kscript-source-answer-budget.leaf.js +39 -0
  23. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +38 -1
  24. package/dist/utility/chart/kscript-source-degrade.leaf.js +39 -1
  25. package/dist/utility/chart/live-bucket.util.d.ts +2 -1
  26. package/dist/utility/chart/live-bucket.util.js +47 -15
  27. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +15 -1
  28. package/dist/utility/chart/local-kscript-warmup-depth.util.js +9 -0
  29. package/dist/utility/chart/market-session-schedule.util.d.ts +3 -1
  30. package/dist/utility/chart/market-session-schedule.util.js +24 -2
  31. package/dist/utility/chart/marketKind.util.d.ts +12 -7
  32. package/dist/utility/chart/marketKind.util.js +15 -5
  33. package/dist/utility/chart/ny-calendar.util.d.ts +104 -0
  34. package/dist/utility/chart/ny-calendar.util.js +346 -0
  35. package/dist/utility/chart/om-panel.util.d.ts +14 -2
  36. package/dist/utility/chart/om-panel.util.js +108 -40
  37. package/dist/utility/chart/rth-session.util.d.ts +10 -7
  38. package/dist/utility/chart/rth-session.util.js +17 -22
  39. package/dist/utility/chart/trading-day.util.js +90 -18
  40. package/dist/utility/chart/us-equities-session.util.js +20 -67
  41. package/dist/utility/chart/wrun-bar-session-facts.util.js +14 -1
  42. package/dist/utility/common/time.util.d.ts +7 -1
  43. package/dist/utility/common/time.util.js +11 -41
  44. package/dist/utility/number-format.util.d.ts +17 -7
  45. package/dist/utility/number-format.util.js +18 -8
  46. package/dist/utility/options/option-symbol.util.js +13 -2
  47. package/dist/utility/symbol-selection/contract-expiry.util.js +9 -1
  48. package/dist/utility/watchlist/import/import-request.leaf.d.ts +4 -1
  49. package/dist/utility/watchlist/import/import-request.leaf.js +5 -2
  50. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +25 -4
  51. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +62 -4
  52. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +19 -0
  53. package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +57 -0
  54. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +23 -0
  55. package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +90 -0
  56. package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.d.ts +39 -0
  57. package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.js +60 -0
  58. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +77 -0
  59. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +195 -0
  60. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +56 -0
  61. package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +70 -0
  62. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +53 -0
  63. package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +239 -0
  64. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +16 -0
  65. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +14 -0
  66. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +43 -18
  67. package/dist/utility/wrun/sources/lanes/options_flow.js +209 -72
  68. package/dist/utility/wrun/sources/lanes/token_supply.js +5 -31
  69. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -18
  70. package/dist/utility/wrun/sources/opra-option-lanes.util.js +12 -57
  71. package/dist/utility/wrun/sources/row-lane-registry.d.ts +1 -1
  72. package/dist/utility/wrun/sources/row-lane-registry.js +22 -8
  73. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +61 -0
  74. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +103 -8
  75. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +5 -0
  76. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +24 -12
  77. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +55 -0
  78. package/dist/utility/wrun/sources/row-lanes/option_prints.js +95 -18
  79. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +15 -1
  80. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +23 -8
  81. package/dist/utility/wrun/sources/row-lanes/option_surface.js +11 -11
  82. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +14 -2
  83. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +6 -3
  84. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +43 -8
  85. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +77 -11
  86. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -16
  87. package/dist/utility/wrun/sources/wrun-row-lane.types.js +2 -0
  88. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +52 -12
  89. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +110 -46
  90. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +10 -0
  91. package/dist/utility/wrun/wrun-browser-sources.leaf.js +12 -0
  92. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +3 -3
  93. package/dist/utility/wrun/wrun-coin-lane-live.util.js +53 -18
  94. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -0
  95. package/dist/utility/wrun/wrun-color-settings.util.js +45 -0
  96. package/dist/utility/wrun/wrun-draft-overlay.util.js +14 -8
  97. package/dist/utility/wrun/wrun-failure-cause.d.ts +1 -1
  98. package/dist/utility/wrun/wrun-failure-cause.js +14 -0
  99. package/dist/utility/wrun/wrun-frames.js +6 -2
  100. package/dist/utility/wrun/wrun-host.service.d.ts +26 -18
  101. package/dist/utility/wrun/wrun-host.service.js +49 -52
  102. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
  103. package/dist/utility/wrun/wrun-hosted-wire-caps.js +2 -0
  104. package/dist/utility/wrun/wrun-input-requirements.leaf.js +7 -4
  105. package/dist/utility/wrun/wrun-kit-run-tables.util.d.ts +24 -0
  106. package/dist/utility/wrun/wrun-kit-run-tables.util.js +87 -0
  107. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +2 -1
  108. package/dist/utility/wrun/wrun-live-tick.util.d.ts +8 -2
  109. package/dist/utility/wrun/wrun-live-tick.util.js +35 -16
  110. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +40 -13
  111. package/dist/utility/wrun/wrun-opra-flow.leaf.js +39 -12
  112. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +70 -21
  113. package/dist/utility/wrun/wrun-option-contract-flow.util.js +257 -112
  114. package/dist/utility/wrun/wrun-option-prints.util.d.ts +62 -22
  115. package/dist/utility/wrun/wrun-option-prints.util.js +148 -46
  116. package/dist/utility/wrun/wrun-option-views.util.d.ts +262 -0
  117. package/dist/utility/wrun/wrun-option-views.util.js +356 -0
  118. package/dist/utility/wrun/wrun-options-chain.util.d.ts +23 -2
  119. package/dist/utility/wrun/wrun-options-chain.util.js +37 -3
  120. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +18 -3
  121. package/dist/utility/wrun/wrun-overlay-drivers.util.js +32 -7
  122. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -3
  123. package/dist/utility/wrun/wrun-overlay-recovery.util.js +146 -18
  124. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +50 -6
  125. package/dist/utility/wrun/wrun-overlay-run.util.js +816 -243
  126. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +5 -0
  127. package/dist/utility/wrun/wrun-pin-spelling.util.js +28 -12
  128. package/dist/utility/wrun/wrun-pin-venues.util.js +4 -6
  129. package/dist/utility/wrun/wrun-present-bits.util.d.ts +9 -0
  130. package/dist/utility/wrun/wrun-present-bits.util.js +39 -0
  131. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +3 -2
  132. package/dist/utility/wrun/wrun-refusal-surface.util.js +5 -4
  133. package/dist/utility/wrun/wrun-refusal.util.d.ts +66 -6
  134. package/dist/utility/wrun/wrun-refusal.util.js +335 -40
  135. package/dist/utility/wrun/wrun-source-rows.util.js +11 -0
  136. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +28 -3
  137. package/dist/utility/wrun/wrun-tier-grid.util.js +79 -19
  138. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +14 -3
  139. package/dist/utility/wrun/wrun-transient-rerun.util.js +33 -8
  140. package/package.json +5 -5
  141. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +0 -12
  142. package/dist/utility/wrun/wrun-opra-underlying.util.js +0 -1
@@ -13,9 +13,10 @@
13
13
  * tiers) or `latest` (no tiers, no tier choice, no fold);
14
14
  * - `governed` is `opra` or absent; `emptyAnswer` is `quiet`, `degrades` or absent; `acquisitions` is `one` or
15
15
  * absent; a `liveByCoin` lane names its script source and its stamp and fold functions, and is no `latest` one;
16
- * a `rowBudget` names a whole row cap and a projection, on a flow or snapshot that carries a present mask;
16
+ * a `rowBudget` names the whole cells of one answered row and a projection (its cap is the source answer budget,
17
+ * never the lane's own), on a flow or snapshot that carries a present mask;
17
18
  * - a `chain` lane names its exchange field, resolves its chain in its identity or facets, and declares no
18
- * `governed` and no `liveByCoin` (its plane is each instance's).
19
+ * `governed` (its plane is each instance's); fed live by coin, its channel is each instance's chain too.
19
20
  *
20
21
  * The consumers read the lookups below at call time, so the one test hook (`__setWrunRowLanesForTest`) swaps the
21
22
  * whole registry for a spec. The folder ships EMPTY of lanes until a class lands (UW-PARITY units U10b, U11).
@@ -26,6 +27,7 @@
26
27
  */
27
28
  // First: the row lane modules evaluate before this module's other imports, the order the bundler glob gave them.
28
29
  import { WRUN_ROW_LANE_MODULES } from './row-lanes/index.js';
30
+ import { WRUN_LANE_CHAIN_PLANES } from './wrun-row-lane.types.js';
29
31
  import { assertWrunHostGridLanding } from './host-grid-landing.js';
30
32
  import { WRUN_BROWSER_BUILTIN_SOURCE_CLASSES, wrunPollLaneClassOfFile } from '../wrun-browser-sources.leaf.js';
31
33
  import { registerWrunRefusalFeedKeys } from '../wrun-refusal.util.js';
@@ -43,8 +45,9 @@ function nonEmptyText(value) {
43
45
  return typeof value === 'string' && value !== '';
44
46
  }
45
47
  /** A chain lane's rules (`chain`): it names the payload field its chain's exchange rides in, resolves that chain in
46
- * its identity or facets, and keeps no per-descriptor plane (`governed`) and no live channel by coin (one plane's
47
- * channel). */
48
+ * its identity or facets, and keeps no per-descriptor plane (`governed`). It may be fed live by coin (`liveByCoin`,
49
+ * `option_prints`): each instance's coin channel names the exchange and the underlying its own chain lists on, never
50
+ * one plane's (wrun-coin-lane-live.util). */
48
51
  function assertWrunRowChainLane(who, lane) {
49
52
  const chain = lane.chain;
50
53
  if (chain === undefined)
@@ -58,8 +61,6 @@ function assertWrunRowChainLane(who, lane) {
58
61
  if (lane.identity === undefined && lane.facets === undefined) {
59
62
  throw new Error(`${who}: a chain lane resolves its chain in its identity or facets`);
60
63
  }
61
- if (lane.liveByCoin !== undefined)
62
- throw new Error(`${who}: a chain lane is polled, never fed live by coin`);
63
64
  }
64
65
  /** Refuse a malformed descriptor set by name (a programming error, never a user's). */
65
66
  function assertWrunRowLanes(lanes) {
@@ -142,8 +143,13 @@ function assertWrunRowLanes(lanes) {
142
143
  if (landing.kind === 'latest' || lane.presentMask === false) {
143
144
  throw new Error(`${who}: a row budget marks the bars it leaves out partial: a flow or snapshot with a present mask`);
144
145
  }
145
- if (!Number.isInteger(budget.maxRows) || budget.maxRows < 1 || typeof budget.barRows !== 'function') {
146
- throw new Error(`${who}: rowBudget is { maxRows: a whole number of rows, barRows: a function } or absent`);
146
+ if ('maxRows' in budget) {
147
+ throw new Error(`${who}: rowBudget names no row cap of its own; the cap is the source answer budget in rows of cellsPerRow`);
148
+ }
149
+ if (!Number.isInteger(budget.cellsPerRow) ||
150
+ budget.cellsPerRow < 1 ||
151
+ typeof budget.barRows !== 'function') {
152
+ throw new Error(`${who}: rowBudget is { cellsPerRow: a whole number of cells, barRows: a function } or absent`);
147
153
  }
148
154
  }
149
155
  const live = lane.liveByCoin;
@@ -158,6 +164,14 @@ function assertWrunRowLanes(lanes) {
158
164
  if (!isFunctionOrAbsent(live.coinOf) || !isFunctionOrAbsent(live.reconcile)) {
159
165
  throw new Error(`${who}: liveByCoin coinOf and reconcile are functions or absent`);
160
166
  }
167
+ const planes = live.chainPlanes;
168
+ if (planes !== undefined &&
169
+ (lane.chain === undefined ||
170
+ !Array.isArray(planes) ||
171
+ planes.length === 0 ||
172
+ !planes.every((plane) => WRUN_LANE_CHAIN_PLANES.includes(plane)))) {
173
+ throw new Error(`${who}: liveByCoin chainPlanes names a chain lane's planes (opra, cme, plain), or is absent`);
174
+ }
161
175
  }
162
176
  }
163
177
  }
@@ -1,2 +1,63 @@
1
+ /**
2
+ * `option_contract_flow` (UW-PARITY source contract v2, S4; on every chain since OPTIONS-PORT P7): one 17-value tuple per
3
+ * contract of the chain's ONE book that traded in the bar (wrun-option-contract-flow.util), summed per host bar from
4
+ * OPTION_PRINT_AGG's CONTRACT rows. A row lane: the host plans, asks under the tier rule, lands and reconciles it from
5
+ * this descriptor.
6
+ *
7
+ * - A CHAIN lane (`chain`): the chain is the one chain resolver's (opra-option-lanes.util `resolveWrunLaneChainChart`
8
+ * in `identity`, then `decideWrunLaneChain` per input in `facets`, the decision `options_chain` and `option_surface`
9
+ * read), and its plane is per instance: OPRA's rules on a US stock or OPRA contract chart (unchanged: the wall, the
10
+ * provenance stamp, the routed tier), CME's on a CME futures chart (a continuous chart reads its lead contract, and a
11
+ * live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. A chart with no option chain
12
+ * is refused by the decision's own name (`no-options` / `chain`), which a declared `missing: "empty"` drops with a
13
+ * note.
14
+ * - The acquisition names the chain: `coin` (the chain's underlying, the key its plane files the rows under),
15
+ * `flowExchange` (its plane follows it), `flowBook` for a book other than the underlying's own series (ONE book per
16
+ * input, D11: the worker keeps that book's rows) and `flowContinuous` for a CME chain read off a continuous alias.
17
+ * - Facets (om's facet list and words): `venue` and `book` (the chain classes' words), `expiries`, `strike_window_pct`
18
+ * and `min_volume` (above 0, in the chain's size unit: contracts on OPRA and CME, coin on a crypto chain), each
19
+ * refused by name outside its words (`wrun_option_knob_invalid`); `max_cells` required (the static plan's rule).
20
+ * - Tiers: 1m kept 7 days, 5m 30, 1h and 1d kept. The fold is tier-invariant (the backend rolls every tier up from
21
+ * the 1m one: sums, the strike window's contract-weighted underlying among them, the newest last price and the
22
+ * newest set IV), so the lane takes the COARSEST tier choice: each host bar reads the coarsest tier that fits it,
23
+ * still holds it and already serves it (a 5m bar one 5m bucket, a sealed daily bar one day bucket; the forming bar a
24
+ * real-time tier; a 09:30 New York stock bar never an hourly bucket), which cuts a liquid underlying's read several
25
+ * times over. A bar none holds is partial. A CME bar of a day or longer is read over its Globex session (the host's
26
+ * flow plan, wrun-tier-grid.util `wrunCmeSessionBarSpan`: from the 17:00 Chicago open before its 00:00Z stamp), so a
27
+ * sealed one reads hour buckets, never a UTC day bucket, which straddles the flip: an evening print folds into the
28
+ * next trade date's bar and its "0dte" reads that trade date.
29
+ * - Row budget: before any fetch the host projects each asked bar's rows on the plane of the instance's chain
30
+ * (`wrunOptionContractFlowBarRows` over the acquisition: OPRA's sessions at SPY's measured rows at the bar's tier,
31
+ * CME's Globex trade days, a crypto chain's UTC days at the busiest crypto chain's measured rows) and keeps the
32
+ * newest bars that fit the source answer budget (kscript-source-answer-budget.leaf, in rows of the raw tuple's 21
33
+ * cells: about 49,900 rows, 1.6 MB on the wire for SPY); every older bar of the window is partial (bit 14, one
34
+ * marker tuple) instead of the read failing. The kept bars are read whole, so they stay complete and exact. SPY at
35
+ * that budget: the newest 0.44 of a session on a 09:30-anchored chart (the 5m tier, about 3 hourly bars), 1.8
36
+ * sessions on a UTC hourly one, 7 on a daily one. Before the budget the cap was the worker's 500,000-row failure
37
+ * cap, ten times over every other layer's limit (2026-10-20 field hang: 25 MB asks that outlived the lane deadline
38
+ * and the row cache's entry cap).
39
+ * - The fold sums each contract over the host bar and applies the knobs that need the whole bar: the N nearest
40
+ * expiries, the strike window around the bar's contract-weighted underlying, the volume floor. "0dte" (a contract
41
+ * expiring on the bucket's trade date, on the chain's market's own clock) is kept per row by the worker twin of
42
+ * `K_OPTION_CONTRACT_FLOW`.
43
+ * - No live channel: the live tick's reconcile re-asks it (a flow: an empty window is quiet).
44
+ *
45
+ * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
46
+ */
47
+ import { type WrunLaneChain } from '../opra-option-lanes.util.js';
1
48
  import type { WrunRowLaneDescriptor } from '../wrun-row-lane.types.js';
49
+ /** Test seam: forget every resolved chart. */
50
+ export declare function __resetWrunContractFlowChartsForTests(): void;
51
+ /**
52
+ * An input's chain as the ask's fields (the acquisition key: the class, the plane its exchange names, the exchange,
53
+ * the underlying, the book and, per ask, the tier): `coin` (the chain's underlying, upper case: an OPRA chain's ticker
54
+ * exactly as before) and `flowExchange` always, `flowBook` for a book other than the underlying's own series (Deribit's
55
+ * BTC_USDC, OKX's BTC-USD), and `flowContinuous` for a CME chain read off a continuous alias
56
+ * (`wrunOptionContractFlowAcquisitionMoved` reads it).
57
+ */
58
+ export declare function wrunOptionContractFlowExtras(chain: WrunLaneChain): Record<string, unknown>;
59
+ /** Whether an acquisition no longer names the contract the lane would plan now (D12): a CME chain read off a
60
+ * continuous alias whose lead rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
61
+ * rebuilds, so no ask, cache or buffer joins the old contract's rows to the new one's. */
62
+ export declare function wrunOptionContractFlowAcquisitionMoved(acquisition: Readonly<Record<string, unknown>>): boolean;
2
63
  export declare const rowLane: WrunRowLaneDescriptor;
@@ -1,17 +1,109 @@
1
+ /**
2
+ * `option_contract_flow` (UW-PARITY source contract v2, S4; on every chain since OPTIONS-PORT P7): one 17-value tuple per
3
+ * contract of the chain's ONE book that traded in the bar (wrun-option-contract-flow.util), summed per host bar from
4
+ * OPTION_PRINT_AGG's CONTRACT rows. A row lane: the host plans, asks under the tier rule, lands and reconciles it from
5
+ * this descriptor.
6
+ *
7
+ * - A CHAIN lane (`chain`): the chain is the one chain resolver's (opra-option-lanes.util `resolveWrunLaneChainChart`
8
+ * in `identity`, then `decideWrunLaneChain` per input in `facets`, the decision `options_chain` and `option_surface`
9
+ * read), and its plane is per instance: OPRA's rules on a US stock or OPRA contract chart (unchanged: the wall, the
10
+ * provenance stamp, the routed tier), CME's on a CME futures chart (a continuous chart reads its lead contract, and a
11
+ * live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. A chart with no option chain
12
+ * is refused by the decision's own name (`no-options` / `chain`), which a declared `missing: "empty"` drops with a
13
+ * note.
14
+ * - The acquisition names the chain: `coin` (the chain's underlying, the key its plane files the rows under),
15
+ * `flowExchange` (its plane follows it), `flowBook` for a book other than the underlying's own series (ONE book per
16
+ * input, D11: the worker keeps that book's rows) and `flowContinuous` for a CME chain read off a continuous alias.
17
+ * - Facets (om's facet list and words): `venue` and `book` (the chain classes' words), `expiries`, `strike_window_pct`
18
+ * and `min_volume` (above 0, in the chain's size unit: contracts on OPRA and CME, coin on a crypto chain), each
19
+ * refused by name outside its words (`wrun_option_knob_invalid`); `max_cells` required (the static plan's rule).
20
+ * - Tiers: 1m kept 7 days, 5m 30, 1h and 1d kept. The fold is tier-invariant (the backend rolls every tier up from
21
+ * the 1m one: sums, the strike window's contract-weighted underlying among them, the newest last price and the
22
+ * newest set IV), so the lane takes the COARSEST tier choice: each host bar reads the coarsest tier that fits it,
23
+ * still holds it and already serves it (a 5m bar one 5m bucket, a sealed daily bar one day bucket; the forming bar a
24
+ * real-time tier; a 09:30 New York stock bar never an hourly bucket), which cuts a liquid underlying's read several
25
+ * times over. A bar none holds is partial. A CME bar of a day or longer is read over its Globex session (the host's
26
+ * flow plan, wrun-tier-grid.util `wrunCmeSessionBarSpan`: from the 17:00 Chicago open before its 00:00Z stamp), so a
27
+ * sealed one reads hour buckets, never a UTC day bucket, which straddles the flip: an evening print folds into the
28
+ * next trade date's bar and its "0dte" reads that trade date.
29
+ * - Row budget: before any fetch the host projects each asked bar's rows on the plane of the instance's chain
30
+ * (`wrunOptionContractFlowBarRows` over the acquisition: OPRA's sessions at SPY's measured rows at the bar's tier,
31
+ * CME's Globex trade days, a crypto chain's UTC days at the busiest crypto chain's measured rows) and keeps the
32
+ * newest bars that fit the source answer budget (kscript-source-answer-budget.leaf, in rows of the raw tuple's 21
33
+ * cells: about 49,900 rows, 1.6 MB on the wire for SPY); every older bar of the window is partial (bit 14, one
34
+ * marker tuple) instead of the read failing. The kept bars are read whole, so they stay complete and exact. SPY at
35
+ * that budget: the newest 0.44 of a session on a 09:30-anchored chart (the 5m tier, about 3 hourly bars), 1.8
36
+ * sessions on a UTC hourly one, 7 on a daily one. Before the budget the cap was the worker's 500,000-row failure
37
+ * cap, ten times over every other layer's limit (2026-10-20 field hang: 25 MB asks that outlived the lane deadline
38
+ * and the row cache's entry cap).
39
+ * - The fold sums each contract over the host bar and applies the knobs that need the whole bar: the N nearest
40
+ * expiries, the strike window around the bar's contract-weighted underlying, the volume floor. "0dte" (a contract
41
+ * expiring on the bucket's trade date, on the chain's market's own clock) is kept per row by the worker twin of
42
+ * `K_OPTION_CONTRACT_FLOW`.
43
+ * - No live channel: the live tick's reconcile re-asks it (a flow: an empty window is quiet).
44
+ *
45
+ * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
46
+ */
47
+ import { decideWrunLaneChain, resolveWrunLaneChainChart, WRUN_OPTION_CHART_UNRESOLVED_CODE, wrunLaneChainLeadMoved, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
48
+ import { refuseWrunPollInput } from '../wrun-poll-lane.types.js';
1
49
  import { refuseWrunOptionKnob, wrunOptionExpiriesKnob, wrunOptionExpiriesWord, wrunOptionStrikeWindowKnob, } from '../../wrun-option-knobs.util.js';
2
- import { foldWrunOptionContractFlowBar, WRUN_OPTION_CONTRACT_FLOW_MAX_ROWS, WRUN_OPTION_CONTRACT_FLOW_WIDTH, WRUN_OPTION_PRINT_AGG_TIERS, wrunOptionContractFlowBarRows, } from '../../wrun-option-contract-flow.util.js';
3
- import { resolveWrunOpraLaneUnderlying } from '../../wrun-opra-underlying.util.js';
50
+ import { foldWrunOptionContractFlowBar, WRUN_OPTION_CONTRACT_FLOW_BOOK_FIELD, WRUN_OPTION_CONTRACT_FLOW_CONTINUOUS_FIELD, WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD, WRUN_OPTION_CONTRACT_FLOW_RAW_WIDTH, WRUN_OPTION_CONTRACT_FLOW_WIDTH, WRUN_OPTION_PRINT_AGG_TIERS, wrunOptionContractFlowBarRows, } from '../../wrun-option-contract-flow.util.js';
51
+ import { wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
4
52
  /** The lane's key, its feed in a refusal record. */
5
53
  const LANE_KEY = 'option_contract_flow';
6
- /** One input's facets: the expiries word, the strike window and the volume floor (each absent when not declared). */
7
- function contractFlowFacets(source, ctx) {
54
+ /** What `identity` resolved for a chart (the one chain resolver's chart), read back by `facets`. Keyed by the chart
55
+ * market; the newest entries kept. */
56
+ const FLOW_CHARTS_KEPT = 16;
57
+ const flowCharts = new Map();
58
+ function rememberFlowChart(key, chart) {
59
+ flowCharts.delete(key);
60
+ flowCharts.set(key, chart);
61
+ while (flowCharts.size > FLOW_CHARTS_KEPT)
62
+ flowCharts.delete(flowCharts.keys().next().value);
63
+ }
64
+ /** Test seam: forget every resolved chart. */
65
+ export function __resetWrunContractFlowChartsForTests() {
66
+ flowCharts.clear();
67
+ }
68
+ /**
69
+ * An input's chain as the ask's fields (the acquisition key: the class, the plane its exchange names, the exchange,
70
+ * the underlying, the book and, per ask, the tier): `coin` (the chain's underlying, upper case: an OPRA chain's ticker
71
+ * exactly as before) and `flowExchange` always, `flowBook` for a book other than the underlying's own series (Deribit's
72
+ * BTC_USDC, OKX's BTC-USD), and `flowContinuous` for a CME chain read off a continuous alias
73
+ * (`wrunOptionContractFlowAcquisitionMoved` reads it).
74
+ */
75
+ export function wrunOptionContractFlowExtras(chain) {
76
+ const coin = chain.underlying.toUpperCase();
77
+ const book = chain.book.toUpperCase();
78
+ return {
79
+ coin,
80
+ [WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD]: chain.exchange,
81
+ ...(book !== coin ? { [WRUN_OPTION_CONTRACT_FLOW_BOOK_FIELD]: book } : {}),
82
+ ...(chain.continuous !== undefined ? { [WRUN_OPTION_CONTRACT_FLOW_CONTINUOUS_FIELD]: chain.continuous } : {}),
83
+ };
84
+ }
85
+ /** Whether an acquisition no longer names the contract the lane would plan now (D12): a CME chain read off a
86
+ * continuous alias whose lead rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
87
+ * rebuilds, so no ask, cache or buffer joins the old contract's rows to the new one's. */
88
+ export function wrunOptionContractFlowAcquisitionMoved(acquisition) {
89
+ return wrunLaneChainLeadMoved(acquisition[WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD], acquisition[WRUN_OPTION_CONTRACT_FLOW_CONTINUOUS_FIELD], acquisition.coin);
90
+ }
91
+ /** One input's facets: the expiries word, the strike window and the volume floor (each absent when not declared),
92
+ * then its chain, decided by the one chain resolver over the chart `identity` resolved (its `venue` and `book`). */
93
+ async function contractFlowFacets(source, ctx) {
8
94
  const expiries = wrunOptionExpiriesWord(wrunOptionExpiriesKnob(source, ctx));
9
95
  const strikeWindowPct = wrunOptionStrikeWindowKnob(source, ctx);
10
96
  const minVolume = source.min_volume;
11
97
  if (minVolume !== undefined && !(typeof minVolume === 'number' && Number.isFinite(minVolume) && minVolume > 0)) {
12
- refuseWrunOptionKnob(ctx, 'min_volume', minVolume, 'a contract count above 0');
98
+ refuseWrunOptionKnob(ctx, 'min_volume', minVolume, 'a size above 0 (contracts, or coin on a crypto chain)');
13
99
  }
100
+ const chart = flowCharts.get(wrunLaneChartKey(ctx));
101
+ if (chart === undefined) {
102
+ return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', wrunAuthorRuleSeed(WRUN_OPTION_CHART_UNRESOLVED_CODE));
103
+ }
104
+ const chain = await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx);
14
105
  return {
106
+ ...wrunOptionContractFlowExtras(chain),
15
107
  ...(expiries !== undefined ? { expiries } : {}),
16
108
  ...(strikeWindowPct !== undefined ? { strikeWindowPct } : {}),
17
109
  ...(minVolume !== undefined ? { minVolume } : {}),
@@ -24,7 +116,11 @@ export const rowLane = {
24
116
  label: 'Option contract flow',
25
117
  feedWords: 'wrun.refusal.feed.optionContractFlow',
26
118
  width: WRUN_OPTION_CONTRACT_FLOW_WIDTH,
27
- identity: async (ctx) => ({ coin: await resolveWrunOpraLaneUnderlying(ctx) }),
119
+ chain: { exchangeField: WRUN_OPTION_CONTRACT_FLOW_EXCHANGE_FIELD },
120
+ acquisitionMoved: wrunOptionContractFlowAcquisitionMoved,
121
+ identity: async (ctx) => {
122
+ rememberFlowChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx));
123
+ },
28
124
  facets: contractFlowFacets,
29
125
  landing: {
30
126
  kind: 'flow',
@@ -32,7 +128,6 @@ export const rowLane = {
32
128
  tierChoice: 'coarsest',
33
129
  fold: (group, acquisition) => foldWrunOptionContractFlowBar(group.rows, acquisition),
34
130
  },
35
- rowBudget: { maxRows: WRUN_OPTION_CONTRACT_FLOW_MAX_ROWS, barRows: wrunOptionContractFlowBarRows },
36
- governed: 'opra',
131
+ rowBudget: { cellsPerRow: WRUN_OPTION_CONTRACT_FLOW_RAW_WIDTH, barRows: wrunOptionContractFlowBarRows },
37
132
  emptyAnswer: 'quiet',
38
133
  };
@@ -28,6 +28,11 @@
28
28
  * the one venue decision names for the word, in `options_chain`'s words; absent reads `auto`, the chain
29
29
  * `options_chain`'s `auto` reads on the same chart); `max_cells` is required (the static plan) and a block over it
30
30
  * refuses the run, never truncated. A market pin and the knobs of the other options classes are refused by name.
31
+ * - Views (OPTLOAD G5, wrun-option-views.util): `page_view` or `page_views` reads a projection of the class's block B
32
+ * in place of B whole (`stateViews`; a view's own params, `min_volume` included, ride as flat knobs). The worker asks
33
+ * the gateway for them in ONE chain summary read; a gateway without the views refuses them by name.
34
+ * - On the OPRA plane the chain is the plane's own by coin (section 8, O1: `wrunHeldOpraPlaneChain`): no chain
35
+ * directory is read before the lane's first ask.
31
36
  *
32
37
  * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
33
38
  */
@@ -28,24 +28,33 @@
28
28
  * the one venue decision names for the word, in `options_chain`'s words; absent reads `auto`, the chain
29
29
  * `options_chain`'s `auto` reads on the same chart); `max_cells` is required (the static plan) and a block over it
30
30
  * refuses the run, never truncated. A market pin and the knobs of the other options classes are refused by name.
31
+ * - Views (OPTLOAD G5, wrun-option-views.util): `page_view` or `page_views` reads a projection of the class's block B
32
+ * in place of B whole (`stateViews`; a view's own params, `min_volume` included, ride as flat knobs). The worker asks
33
+ * the gateway for them in ONE chain summary read; a gateway without the views refuses them by name.
34
+ * - On the OPRA plane the chain is the plane's own by coin (section 8, O1: `wrunHeldOpraPlaneChain`): no chain
35
+ * directory is read before the lane's first ask.
31
36
  *
32
37
  * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
33
38
  */
34
- import { decideWrunLaneChain, refuseWrunLaneStrayKnob, resolveWrunLaneChainChart, wrunLaneChainLeadMoved, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
39
+ import { decideWrunLaneChain, refuseWrunLaneStrayKnob, resolveWrunLaneChainChart, WRUN_OPTION_CHART_UNRESOLVED_CODE, wrunLaneChainLeadMoved, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
35
40
  import { refuseWrunPollInput } from '../wrun-poll-lane.types.js';
36
41
  import { wrunOptionExpiriesKnob, wrunOptionExpiriesText, wrunOptionStrikeWindowKnob, } from '../../wrun-option-knobs.util.js';
42
+ import { wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
43
+ import { wrunHeldOpraPlaneChain, wrunOptionViewLaneFields, wrunOptionViewParamKnobs, wrunOptionViewsOfSource, } from '../../wrun-option-views.util.js';
37
44
  /** f64s per tuple (the source contract's width, the `present` mask included). */
38
45
  export const WRUN_OPTION_CONTRACT_STATE_WIDTH = 13;
39
46
  /** om's code for a market pin on the OPRA classes. */
40
47
  export const WRUN_OPTION_MARKET_PINNED_CODE = 'wrun_option_market_pinned';
41
48
  /** The payload field an instance names its chain's exchange in (its plane follows it). */
42
49
  export const WRUN_OPTION_CONTRACT_STATE_EXCHANGE_FIELD = 'stateExchange';
43
- /** The knobs of the other options classes, each refused here by name (`venue` is this class's own since kit 0.87.0). */
50
+ /** The knobs of the other options classes, each refused here by name (`venue` is this class's own since kit 0.87.0;
51
+ * the print classes' knobs are option_prints_v2's too, and `structure` its own, since kit 0.88.0). */
44
52
  const STRAY_KNOBS = [
45
- ['history', "'tape' and 'option_prints' celled"],
53
+ ['history', "'tape', 'option_prints' and 'option_prints_v2' celled"],
46
54
  ['min_size', "'tape' celled"],
47
- ['min_premium', "'option_prints' celled"],
48
- ['overflow', "'option_prints' celled"],
55
+ ['min_premium', "'option_prints' and 'option_prints_v2' celled"],
56
+ ['overflow', "'option_prints' and 'option_prints_v2' celled"],
57
+ ['structure', "'option_prints_v2' celled"],
49
58
  ['min_volume', "'option_contract_flow' celled"],
50
59
  ];
51
60
  /** What `identity` resolved for a chart (the one chain resolver's chart), read back by `facets`. Keyed by the chart
@@ -95,31 +104,34 @@ export const rowLane = {
95
104
  landing: { kind: 'latest' },
96
105
  acquisitionMoved: wrunOptionContractStateAcquisitionMoved,
97
106
  identity: async (ctx) => {
98
- rememberStateChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx));
107
+ // On the OPRA plane the chain is the plane's own by coin: no chain directory is read (O1).
108
+ const held = await wrunHeldOpraPlaneChain(ctx.exchange, ctx.coin, ctx.opraPlane);
109
+ rememberStateChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx, held));
99
110
  },
100
111
  facets: async (source, ctx) => {
112
+ // A knob a declared view takes is that view's param, never another class's stray knob.
113
+ const viewKnobs = wrunOptionViewParamKnobs(source);
101
114
  for (const [knob, owners] of STRAY_KNOBS) {
102
- if (source[knob] !== undefined)
115
+ if (source[knob] !== undefined && !viewKnobs.has(knob))
103
116
  refuseWrunLaneStrayKnob(ctx, knob, owners);
104
117
  }
105
118
  if (source.symbol !== undefined || source.exchange !== undefined) {
106
- refuseWrunPollInput(ctx, `pins option_contract_state cells to a fixed market (${WRUN_OPTION_MARKET_PINNED_CODE}); it reads the chart's own underlying, so drop the symbol and exchange pin`, { cls: 'run-failed', variant: 'generic' });
119
+ refuseWrunPollInput(ctx, `pins option_contract_state cells to a fixed market (${WRUN_OPTION_MARKET_PINNED_CODE}); it reads the chart's own underlying, so drop the symbol and exchange pin`, wrunAuthorRuleSeed(WRUN_OPTION_MARKET_PINNED_CODE));
107
120
  }
108
121
  // om's knob words and its one refusal name (`wrun_option_knob_invalid`), as every options class refuses them.
109
122
  const expiries = wrunOptionExpiriesKnob(source, ctx);
110
123
  const strikeWindowPct = wrunOptionStrikeWindowKnob(source, ctx);
111
124
  const chart = stateCharts.get(wrunLaneChartKey(ctx));
112
125
  if (chart === undefined) {
113
- return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', {
114
- cls: 'run-failed',
115
- variant: 'generic',
116
- });
126
+ return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', wrunAuthorRuleSeed(WRUN_OPTION_CHART_UNRESOLVED_CODE));
117
127
  }
128
+ const views = wrunOptionViewsOfSource(source, ctx, 'option_contract_state');
118
129
  const chain = await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx);
119
130
  return {
120
131
  ...wrunOptionContractStateExtras(chain),
121
132
  stateExpiries: wrunOptionExpiriesText(expiries),
122
133
  ...(strikeWindowPct !== undefined ? { stateStrikeWindowPct: strikeWindowPct } : {}),
134
+ ...(views !== undefined ? wrunOptionViewLaneFields('option_contract_state', views) : {}),
123
135
  };
124
136
  },
125
137
  };
@@ -1,4 +1,59 @@
1
+ /**
2
+ * `option_prints` (UW-PARITY source contract v2, S3; on every chain since OPTIONS-PORT P7): every print of the chain's
3
+ * ONE book at or above the input's `min_premium`, one 16-value tuple per print on the bar it printed in
4
+ * (wrun-option-prints.util), history plus live. A row lane: the host plans, asks, lands and reconciles it from this
5
+ * descriptor.
6
+ *
7
+ * - A CHAIN lane (`chain`): the chain is the one chain resolver's (opra-option-lanes.util `resolveWrunLaneChainChart`
8
+ * in `identity`, then `decideWrunLaneChain` per input in `facets`, the decision `options_chain` and `option_surface`
9
+ * read), and its plane is per instance: OPRA's rules on a US stock or OPRA contract chart (unchanged: the wall, the
10
+ * provenance stamp, the routed tier), CME's on a CME futures chart (a continuous chart reads its lead contract, and a
11
+ * live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. A chart with no option chain
12
+ * is refused by the decision's own name (`no-options` / `chain`), which a declared `missing: "empty"` drops with a
13
+ * note.
14
+ * - The acquisition names the chain: `coin` (the chain's underlying, the key its plane files prints under),
15
+ * `printExchange` (its plane follows it), `printBook` for a book other than the underlying's own series (ONE book per
16
+ * input, D11: the worker and the live fold keep that book's prints) and `printContinuous` for a CME chain read off a
17
+ * continuous alias.
18
+ * - Facets (the acquisition, om's facet list and words): `min_premium` (required: `wrun_option_prints_min_premium_
19
+ * required`), `expiries`, `history` ("live" | "3d" | "90d") and `overflow` ("refuse" | "largest"), each refused by
20
+ * name outside its words (`wrun_option_knob_invalid`), and the chain classes' `venue` and `book`. One acquisition a
21
+ * package: two inputs whose knobs or chains differ refuse by name.
22
+ * - History: one ask over the window from the span the backend serves the acquisition (`horizon`: the table the
23
+ * floor and the history reach, the gateway's bar limit); older bars are partial. The K control `K_OPTION_PRINT`
24
+ * reads it on the native-rows path, keyed by second; the landing re-bases each print's offset on its host bar.
25
+ * - Projection, per input: `expiries: "nearest:N"` keeps the bar's N nearest expiries; `overflow: "largest"` cuts a
26
+ * bar over the input's own `max_cells` to its largest premiums (om's packer rule, bit 14 on the first kept print).
27
+ * - Live by coin, on the planes whose OPTION_PRINT producer streams (`chainPlanes`: OPRA and CME): the coin channel of
28
+ * the instance's chain (`K_OPTION_PRINT` subscribes the chain's exchange and underlying, on a governed exchange at a
29
+ * real-time routed tier only: wrun-coin-lane-live.util) feeds every print of the underlying; the fold keeps the
30
+ * acquisition's chain (its exchange and its ONE book), its floor and "0dte"; a reconcile merges by `print_key`, so a
31
+ * print shown live never vanishes and one seen on both paths is one tuple. A crypto chain subscribes no channel: the
32
+ * gateway derives its prints from the venue trades ore stores each minute and serves them from history alone (no
33
+ * frame ever reaches a crypto coin channel), so the live tick's reconcile re-asks it, as it re-asks
34
+ * `option_contract_flow`, and the same merge by `print_key` keeps every print once. Never a TRADE channel: the browser
35
+ * builds no print from trades.
36
+ * - A CME chart's daily or longer bar is asked over its Globex session (the host's flow plan, wrun-tier-grid.util
37
+ * `wrunCmeSessionBarSpan`): an evening print belongs to the next trade date's bar, stamped 00:00Z, so its offset on it
38
+ * reads below 0.
39
+ *
40
+ * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
41
+ */
42
+ import { type WrunLaneChain } from '../opra-option-lanes.util.js';
1
43
  import type { WrunRowLaneDescriptor } from '../wrun-row-lane.types.js';
2
44
  /** om's refusal name of a missing floor. */
3
45
  export declare const WRUN_OPTION_PRINTS_MIN_PREMIUM_REQUIRED_CODE = "wrun_option_prints_min_premium_required";
46
+ /** Test seam: forget every resolved chart. */
47
+ export declare function __resetWrunPrintsChartsForTests(): void;
48
+ /**
49
+ * An input's chain as the ask's fields (the acquisition key: the class, the plane its exchange names, the exchange,
50
+ * the underlying and the book): `coin` (the chain's underlying, upper case: an OPRA chain's ticker exactly as before)
51
+ * and `printExchange` always, `printBook` for a book other than the underlying's own series (Deribit's BTC_USDC, OKX's
52
+ * BTC-USD), and `printContinuous` for a CME chain read off a continuous alias (`wrunOptionPrintsAcquisitionMoved`).
53
+ */
54
+ export declare function wrunOptionPrintsExtras(chain: WrunLaneChain): Record<string, unknown>;
55
+ /** Whether an acquisition no longer names the contract the lane would plan now (D12): a CME chain read off a
56
+ * continuous alias whose lead rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
57
+ * rebuilds, so no ask, live fold or buffer joins the old contract's prints to the new one's. */
58
+ export declare function wrunOptionPrintsAcquisitionMoved(acquisition: Readonly<Record<string, unknown>>): boolean;
4
59
  export declare const rowLane: WrunRowLaneDescriptor;
@@ -1,34 +1,94 @@
1
1
  /**
2
- * `option_prints` (UW-PARITY source contract v2, S3): every OPRA print of the chart's underlying at or above the
3
- * input's `min_premium`, one 16-value tuple per print on the bar it printed in (wrun-option-prints.util), history
4
- * plus live. A row lane: the host plans, asks, lands and reconciles it from this descriptor.
2
+ * `option_prints` (UW-PARITY source contract v2, S3; on every chain since OPTIONS-PORT P7): every print of the chain's
3
+ * ONE book at or above the input's `min_premium`, one 16-value tuple per print on the bar it printed in
4
+ * (wrun-option-prints.util), history plus live. A row lane: the host plans, asks, lands and reconciles it from this
5
+ * descriptor.
5
6
  *
6
- * - Identity: the underlying the OPRA plane keys prints by (`coin`), resolved before any fetch.
7
+ * - A CHAIN lane (`chain`): the chain is the one chain resolver's (opra-option-lanes.util `resolveWrunLaneChainChart`
8
+ * in `identity`, then `decideWrunLaneChain` per input in `facets`, the decision `options_chain` and `option_surface`
9
+ * read), and its plane is per instance: OPRA's rules on a US stock or OPRA contract chart (unchanged: the wall, the
10
+ * provenance stamp, the routed tier), CME's on a CME futures chart (a continuous chart reads its lead contract, and a
11
+ * live session rebuilds once the lead rolls: `acquisitionMoved`), none on a crypto chain. A chart with no option chain
12
+ * is refused by the decision's own name (`no-options` / `chain`), which a declared `missing: "empty"` drops with a
13
+ * note.
14
+ * - The acquisition names the chain: `coin` (the chain's underlying, the key its plane files prints under),
15
+ * `printExchange` (its plane follows it), `printBook` for a book other than the underlying's own series (ONE book per
16
+ * input, D11: the worker and the live fold keep that book's prints) and `printContinuous` for a CME chain read off a
17
+ * continuous alias.
7
18
  * - Facets (the acquisition, om's facet list and words): `min_premium` (required: `wrun_option_prints_min_premium_
8
19
  * required`), `expiries`, `history` ("live" | "3d" | "90d") and `overflow` ("refuse" | "largest"), each refused by
9
- * name outside its words (`wrun_option_knob_invalid`). One acquisition a package: two inputs whose knobs differ
10
- * refuse by name.
20
+ * name outside its words (`wrun_option_knob_invalid`), and the chain classes' `venue` and `book`. One acquisition a
21
+ * package: two inputs whose knobs or chains differ refuse by name.
11
22
  * - History: one ask over the window from the span the backend serves the acquisition (`horizon`: the table the
12
23
  * floor and the history reach, the gateway's bar limit); older bars are partial. The K control `K_OPTION_PRINT`
13
24
  * reads it on the native-rows path, keyed by second; the landing re-bases each print's offset on its host bar.
14
25
  * - Projection, per input: `expiries: "nearest:N"` keeps the bar's N nearest expiries; `overflow: "largest"` cuts a
15
26
  * bar over the input's own `max_cells` to its largest premiums (om's packer rule, bit 14 on the first kept print).
16
- * - Live by coin: the coin-scoped OPRA channel (`K_OPTION_PRINT` subscribes it at a real-time routed tier only) feeds
17
- * every print of the underlying; the fold keeps the acquisition's floor and "0dte"; a reconcile merges by
18
- * `print_key`, so a print shown live never vanishes and one seen on both paths is one tuple.
27
+ * - Live by coin, on the planes whose OPTION_PRINT producer streams (`chainPlanes`: OPRA and CME): the coin channel of
28
+ * the instance's chain (`K_OPTION_PRINT` subscribes the chain's exchange and underlying, on a governed exchange at a
29
+ * real-time routed tier only: wrun-coin-lane-live.util) feeds every print of the underlying; the fold keeps the
30
+ * acquisition's chain (its exchange and its ONE book), its floor and "0dte"; a reconcile merges by `print_key`, so a
31
+ * print shown live never vanishes and one seen on both paths is one tuple. A crypto chain subscribes no channel: the
32
+ * gateway derives its prints from the venue trades ore stores each minute and serves them from history alone (no
33
+ * frame ever reaches a crypto coin channel), so the live tick's reconcile re-asks it, as it re-asks
34
+ * `option_contract_flow`, and the same merge by `print_key` keeps every print once. Never a TRADE channel: the browser
35
+ * builds no print from trades.
36
+ * - A CME chart's daily or longer bar is asked over its Globex session (the host's flow plan, wrun-tier-grid.util
37
+ * `wrunCmeSessionBarSpan`): an evening print belongs to the next trade date's bar, stamped 00:00Z, so its offset on it
38
+ * reads below 0.
39
+ *
40
+ * LIGHT at module load: the chain resolver's directory, listing and lead reads run inside `identity` and `facets`.
19
41
  */
42
+ import { decideWrunLaneChain, resolveWrunLaneChainChart, WRUN_OPTION_CHART_UNRESOLVED_CODE, wrunLaneChainLeadMoved, wrunLaneChartKey, } from '../opra-option-lanes.util.js';
20
43
  import { refuseWrunPollInput, WRUN_POLL_AUTHOR_GATE_SEED } from '../wrun-poll-lane.types.js';
21
44
  import { refuseWrunOptionKnob, wrunNearestExpiryTuples, wrunOptionExpiriesKnob, wrunOptionExpiriesOf, wrunOptionExpiriesWord, } from '../../wrun-option-knobs.util.js';
22
- import { isWrunOptionPrintTuple, WRUN_OPTION_PRINT_COLUMN, WRUN_OPTION_PRINTS_HISTORY, WRUN_OPTION_PRINTS_OVERFLOW, WRUN_OPTION_PRINTS_WIDTH, wrunLargestPremiumPrints, wrunOptionPrintKept, wrunOptionPrintOf, wrunOptionPrintsAcquisitionOf, wrunOptionPrintsHorizon, wrunOptionPrintsInTimeOrder, wrunOptionPrintTimeMs, } from '../../wrun-option-prints.util.js';
23
- import { resolveWrunOpraLaneUnderlying } from '../../wrun-opra-underlying.util.js';
45
+ import { isWrunOptionPrintTuple, WRUN_OPTION_PRINT_COLUMN, WRUN_OPTION_PRINTS_BOOK_FIELD, WRUN_OPTION_PRINTS_CONTINUOUS_FIELD, WRUN_OPTION_PRINTS_EXCHANGE_FIELD, WRUN_OPTION_PRINTS_HISTORY, WRUN_OPTION_PRINTS_OVERFLOW, WRUN_OPTION_PRINTS_WIDTH, wrunLargestPremiumPrints, wrunOptionPrintKept, wrunOptionPrintOf, wrunOptionPrintsAcquisitionOf, wrunOptionPrintsHorizon, wrunOptionPrintsInTimeOrder, wrunOptionPrintTimeMs, } from '../../wrun-option-prints.util.js';
24
46
  import { wrunPartialMarkerTuple, wrunPresentIsPartial, wrunTuplesMarkedPartial } from '../../wrun-present-bits.util.js';
47
+ import { wrunAuthorRuleSeed } from '../../wrun-refusal.util.js';
25
48
  import { wrunHostBarOf } from '../../wrun-tier-grid.util.js';
26
49
  /** The lane's key, its feed in a refusal record. */
27
50
  const LANE_KEY = 'option_prints';
28
51
  /** om's refusal name of a missing floor. */
29
52
  export const WRUN_OPTION_PRINTS_MIN_PREMIUM_REQUIRED_CODE = 'wrun_option_prints_min_premium_required';
30
- /** One input's facets: the floor (required), the history, the overflow rule and the expiries word. */
31
- function optionPrintsFacets(source, ctx) {
53
+ /** What `identity` resolved for a chart (the one chain resolver's chart), read back by `facets`. Keyed by the chart
54
+ * market; the newest entries kept. */
55
+ const PRINTS_CHARTS_KEPT = 16;
56
+ const printsCharts = new Map();
57
+ function rememberPrintsChart(key, chart) {
58
+ printsCharts.delete(key);
59
+ printsCharts.set(key, chart);
60
+ while (printsCharts.size > PRINTS_CHARTS_KEPT)
61
+ printsCharts.delete(printsCharts.keys().next().value);
62
+ }
63
+ /** Test seam: forget every resolved chart. */
64
+ export function __resetWrunPrintsChartsForTests() {
65
+ printsCharts.clear();
66
+ }
67
+ /**
68
+ * An input's chain as the ask's fields (the acquisition key: the class, the plane its exchange names, the exchange,
69
+ * the underlying and the book): `coin` (the chain's underlying, upper case: an OPRA chain's ticker exactly as before)
70
+ * and `printExchange` always, `printBook` for a book other than the underlying's own series (Deribit's BTC_USDC, OKX's
71
+ * BTC-USD), and `printContinuous` for a CME chain read off a continuous alias (`wrunOptionPrintsAcquisitionMoved`).
72
+ */
73
+ export function wrunOptionPrintsExtras(chain) {
74
+ const coin = chain.underlying.toUpperCase();
75
+ const book = chain.book.toUpperCase();
76
+ return {
77
+ coin,
78
+ [WRUN_OPTION_PRINTS_EXCHANGE_FIELD]: chain.exchange,
79
+ ...(book !== coin ? { [WRUN_OPTION_PRINTS_BOOK_FIELD]: book } : {}),
80
+ ...(chain.continuous !== undefined ? { [WRUN_OPTION_PRINTS_CONTINUOUS_FIELD]: chain.continuous } : {}),
81
+ };
82
+ }
83
+ /** Whether an acquisition no longer names the contract the lane would plan now (D12): a CME chain read off a
84
+ * continuous alias whose lead rolled since the run planned it (`wrunLaneChainLeadMoved`). A live session holding it
85
+ * rebuilds, so no ask, live fold or buffer joins the old contract's prints to the new one's. */
86
+ export function wrunOptionPrintsAcquisitionMoved(acquisition) {
87
+ return wrunLaneChainLeadMoved(acquisition[WRUN_OPTION_PRINTS_EXCHANGE_FIELD], acquisition[WRUN_OPTION_PRINTS_CONTINUOUS_FIELD], acquisition.coin);
88
+ }
89
+ /** One input's facets: the floor (required), the history, the overflow rule and the expiries word, then its chain,
90
+ * decided by the one chain resolver over the chart `identity` resolved (its `venue` and `book`). */
91
+ async function optionPrintsFacets(source, ctx) {
32
92
  const minPremium = source.min_premium;
33
93
  if (minPremium === undefined) {
34
94
  return refuseWrunPollInput(ctx, `declares no min_premium (${WRUN_OPTION_PRINTS_MIN_PREMIUM_REQUIRED_CODE}): declare the smallest premium a print ` +
@@ -46,7 +106,18 @@ function optionPrintsFacets(source, ctx) {
46
106
  return refuseWrunOptionKnob(ctx, 'overflow', overflow, WRUN_OPTION_PRINTS_OVERFLOW.join(', '));
47
107
  }
48
108
  const expiries = wrunOptionExpiriesWord(wrunOptionExpiriesKnob(source, ctx));
49
- return { minPremium, history, overflow, ...(expiries !== undefined ? { expiries } : {}) };
109
+ const chart = printsCharts.get(wrunLaneChartKey(ctx));
110
+ if (chart === undefined) {
111
+ return refuseWrunPollInput(ctx, 'could not resolve the chart market for its options chain: Run again', wrunAuthorRuleSeed(WRUN_OPTION_CHART_UNRESOLVED_CODE));
112
+ }
113
+ const chain = await decideWrunLaneChain(chart, { venue: source.venue, book: source.book }, ctx);
114
+ return {
115
+ ...wrunOptionPrintsExtras(chain),
116
+ minPremium,
117
+ history,
118
+ overflow,
119
+ ...(expiries !== undefined ? { expiries } : {}),
120
+ };
50
121
  }
51
122
  /** A host bar's prints: each second row's prints, their offsets re-based on the bar's open, in time order. */
52
123
  function landOptionPrints(group) {
@@ -102,8 +173,9 @@ function mergeBarPrints(existing, incoming) {
102
173
  ? wrunTuplesMarkedPartial(prints, WRUN_OPTION_PRINTS_WIDTH)
103
174
  : [wrunPartialMarkerTuple(WRUN_OPTION_PRINTS_WIDTH)];
104
175
  }
105
- /** Live prints folded into the instance's host-bar rows: each kept print (the acquisition's floor and "0dte") on
106
- * the bar holding it, once per `print_key`, every touched bar's prints in time order. */
176
+ /** Live prints folded into the instance's host-bar rows: each kept print (the acquisition's chain, its exchange and
177
+ * its ONE book, its floor and "0dte": a coin channel of another venue or book feeds nothing here) on the bar holding
178
+ * it, once per `print_key`, every touched bar's prints in time order. */
107
179
  function foldLiveOptionPrints(rows, points, ctx) {
108
180
  const acquisition = wrunOptionPrintsAcquisitionOf(ctx.acquisition);
109
181
  const byBar = new Map(rows.map((row) => [Number(row[0]), [...row]]));
@@ -171,16 +243,21 @@ export const rowLane = {
171
243
  label: 'Option prints',
172
244
  feedWords: 'wrun.refusal.feed.optionPrints',
173
245
  width: WRUN_OPTION_PRINTS_WIDTH,
174
- identity: async (ctx) => ({ coin: await resolveWrunOpraLaneUnderlying(ctx) }),
246
+ chain: { exchangeField: WRUN_OPTION_PRINTS_EXCHANGE_FIELD },
247
+ acquisitionMoved: wrunOptionPrintsAcquisitionMoved,
248
+ identity: async (ctx) => {
249
+ rememberPrintsChart(wrunLaneChartKey(ctx), await resolveWrunLaneChainChart(ctx));
250
+ },
175
251
  facets: optionPrintsFacets,
176
252
  acquisitions: 'one',
177
253
  landing: { kind: 'flow', fold: landOptionPrints },
178
254
  horizon: wrunOptionPrintsHorizon,
179
- governed: 'opra',
180
255
  emptyAnswer: 'quiet',
181
256
  cells: projectOptionPrints,
182
257
  liveByCoin: {
183
258
  scriptSource: 'option_print',
259
+ // The planes whose OPTION_PRINT producer streams live (a crypto chain's prints are derived each minute: history).
260
+ chainPlanes: ['opra', 'cme'],
184
261
  stampOf: (point) => {
185
262
  const tsMs = wrunOptionPrintTimeMs(livePrintOf(point).print?.timestamp);
186
263
  return Number.isFinite(tsMs) ? tsMs : null;