@orangecharts/wrun-chart-host 0.5.0 → 0.7.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.
- package/README.md +17 -8
- package/dist/constants/feature-flags.constants.js +7 -2
- package/dist/constants/marketCapabilities.constants.d.ts +5 -0
- package/dist/constants/marketCapabilities.constants.js +16 -0
- package/dist/host-env.d.ts +3 -19
- package/dist/host-ports.types.d.ts +36 -17
- package/dist/index.d.ts +12 -1
- package/dist/index.js +12 -1
- package/dist/indicators/controls/tpo-session.util.js +42 -18
- package/dist/interfaces/wrun-runtime.interface.d.ts +88 -13
- package/dist/interfaces/wrun-runtime.interface.js +17 -3
- package/dist/market-data/billing.interface.d.ts +2 -1
- package/dist/settings-templates/indicator-fields.js +10 -0
- package/dist/utility/chart/chart-mount-epoch.util.d.ts +12 -0
- package/dist/utility/chart/chart-mount-epoch.util.js +32 -0
- package/dist/utility/chart/crypto-index.leaf.d.ts +16 -0
- package/dist/utility/chart/crypto-index.leaf.js +19 -0
- package/dist/utility/chart/index-mode-admission.util.js +9 -1
- package/dist/utility/chart/index-mode.util.d.ts +11 -5
- package/dist/utility/chart/index-mode.util.js +22 -10
- package/dist/utility/chart/kscript-source-answer-budget.leaf.d.ts +36 -0
- package/dist/utility/chart/kscript-source-answer-budget.leaf.js +39 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +38 -1
- package/dist/utility/chart/kscript-source-degrade.leaf.js +39 -1
- package/dist/utility/chart/live-bucket.util.d.ts +2 -1
- package/dist/utility/chart/live-bucket.util.js +47 -15
- package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +15 -1
- package/dist/utility/chart/local-kscript-warmup-depth.util.js +9 -0
- package/dist/utility/chart/market-session-schedule.util.d.ts +3 -1
- package/dist/utility/chart/market-session-schedule.util.js +24 -2
- package/dist/utility/chart/marketKind.util.d.ts +12 -7
- package/dist/utility/chart/marketKind.util.js +15 -5
- package/dist/utility/chart/ny-calendar.util.d.ts +104 -0
- package/dist/utility/chart/ny-calendar.util.js +346 -0
- package/dist/utility/chart/om-panel.util.d.ts +14 -2
- package/dist/utility/chart/om-panel.util.js +108 -40
- package/dist/utility/chart/rth-session.util.d.ts +10 -7
- package/dist/utility/chart/rth-session.util.js +17 -22
- package/dist/utility/chart/trading-day.util.js +90 -18
- package/dist/utility/chart/us-equities-session.util.js +20 -67
- package/dist/utility/chart/wrun-bar-session-facts.util.js +14 -1
- package/dist/utility/common/time.util.d.ts +7 -1
- package/dist/utility/common/time.util.js +11 -41
- package/dist/utility/number-format.util.d.ts +17 -7
- package/dist/utility/number-format.util.js +18 -8
- package/dist/utility/options/option-symbol.util.js +13 -2
- package/dist/utility/symbol-selection/contract-expiry.util.js +9 -1
- package/dist/utility/watchlist/import/import-request.leaf.d.ts +4 -1
- package/dist/utility/watchlist/import/import-request.leaf.js +5 -2
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +25 -4
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +62 -4
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.d.ts +19 -0
- package/dist/utility/wrun/run-schedule/wrun-chart-gate-reader.util.js +57 -0
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.d.ts +23 -0
- package/dist/utility/wrun/run-schedule/wrun-gate-reader-warm.util.js +90 -0
- package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.d.ts +39 -0
- package/dist/utility/wrun/run-schedule/wrun-lane-groups.util.js +60 -0
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +77 -0
- package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +195 -0
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.d.ts +56 -0
- package/dist/utility/wrun/run-schedule/wrun-own-candles.util.js +70 -0
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.d.ts +53 -0
- package/dist/utility/wrun/run-schedule/wrun-prefix-feeds.util.js +239 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +16 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +14 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +43 -18
- package/dist/utility/wrun/sources/lanes/options_flow.js +209 -72
- package/dist/utility/wrun/sources/lanes/token_supply.js +5 -31
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -18
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +12 -57
- package/dist/utility/wrun/sources/row-lane-registry.d.ts +1 -1
- package/dist/utility/wrun/sources/row-lane-registry.js +22 -8
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +61 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +103 -8
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +5 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +24 -12
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +55 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +95 -18
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +15 -1
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +23 -8
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +11 -11
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +14 -2
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +6 -3
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +43 -8
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +77 -11
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +31 -16
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +2 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +52 -12
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +110 -46
- package/dist/utility/wrun/wrun-bar-count.util.d.ts +17 -6
- package/dist/utility/wrun/wrun-bar-count.util.js +27 -12
- package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +10 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +12 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-coin-lane-live.util.js +53 -18
- package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +45 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.js +14 -8
- package/dist/utility/wrun/wrun-failure-cause.d.ts +1 -1
- package/dist/utility/wrun/wrun-failure-cause.js +14 -0
- package/dist/utility/wrun/wrun-frames.js +6 -2
- package/dist/utility/wrun/wrun-host.service.d.ts +131 -59
- package/dist/utility/wrun/wrun-host.service.js +391 -194
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +1 -1
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +2 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-hover.util.js +25 -4
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +7 -4
- package/dist/utility/wrun/wrun-kit-run-tables.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-kit-run-tables.util.js +87 -0
- package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +2 -1
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +8 -2
- package/dist/utility/wrun/wrun-live-tick.util.js +35 -16
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +40 -13
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +39 -12
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +70 -21
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +257 -112
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +62 -22
- package/dist/utility/wrun/wrun-option-prints.util.js +148 -46
- package/dist/utility/wrun/wrun-option-views.util.d.ts +262 -0
- package/dist/utility/wrun/wrun-option-views.util.js +356 -0
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +23 -2
- package/dist/utility/wrun/wrun-options-chain.util.js +37 -3
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +20 -5
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +32 -7
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +9 -3
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +146 -18
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +52 -8
- package/dist/utility/wrun/wrun-overlay-run.util.js +816 -243
- package/dist/utility/wrun/wrun-pack.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +28 -12
- package/dist/utility/wrun/wrun-pin-venues.util.js +4 -6
- package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-prefix-cohort.util.js +1 -1
- package/dist/utility/wrun/wrun-present-bits.util.d.ts +9 -0
- package/dist/utility/wrun/wrun-present-bits.util.js +39 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-refusal-surface.util.js +5 -4
- package/dist/utility/wrun/wrun-refusal.util.d.ts +66 -6
- package/dist/utility/wrun/wrun-refusal.util.js +335 -40
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +2 -2
- package/dist/utility/wrun/wrun-sha256.leaf.d.ts +13 -0
- package/dist/utility/wrun/wrun-sha256.leaf.js +84 -0
- package/dist/utility/wrun/wrun-source-rows.util.js +11 -0
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +28 -3
- package/dist/utility/wrun/wrun-tier-grid.util.js +79 -19
- package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +14 -3
- package/dist/utility/wrun/wrun-transient-rerun.util.js +33 -8
- package/dist/workers/wrun/wrun-abi-host.d.ts +15 -2
- package/dist/workers/wrun/wrun-abi-host.js +31 -12
- package/dist/workers/wrun/wrun-engine-handler.d.ts +11 -28
- package/dist/workers/wrun/wrun-engine-handler.js +181 -12
- package/package.json +5 -5
- package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +0 -12
- package/dist/utility/wrun/wrun-opra-underlying.util.js +0 -1
|
@@ -14,9 +14,17 @@
|
|
|
14
14
|
* when string slots are declared.
|
|
15
15
|
* - Response: `ready` (Uint8Array) + `outputs` (Float64Array, row-major at
|
|
16
16
|
* the output count), plus the packed string table when slots are declared.
|
|
17
|
-
* - Every buffer is transferred, never structured-cloned
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* - Every row and output buffer is transferred, never structured-cloned.
|
|
18
|
+
* - The module crosses as its original BYTES, never as a compiled
|
|
19
|
+
* `WebAssembly.Module` (the shared engine protocol, wrun-chart-host 0.6.0):
|
|
20
|
+
* `module-load` hands the worker the bytes once to hash, verify against the
|
|
21
|
+
* sheet's pin, clamp, prepare and compile, and answers the client's opaque
|
|
22
|
+
* handle (`WrunModuleHandle`); every full run and live-start names the
|
|
23
|
+
* compiled module by its key and carries the bytes again (copied by
|
|
24
|
+
* structured clone, never transferred), so a worker that lost its cache
|
|
25
|
+
* (a respawn, an eviction) compiles them again. The worker answers
|
|
26
|
+
* `{ id, running: true }` once the module is instantiated (the request
|
|
27
|
+
* executes from there), and the run's deadline starts there.
|
|
20
28
|
*/
|
|
21
29
|
import type { WrunHandleDefaultsByKind, WrunHandleKind, WrunHandleRecord, WrunLabelPosition, WrunTextStyle } from '../utility/wrun/wrun-handles.util.js';
|
|
22
30
|
import type { WrunParamHostFill, WrunWarmupWindow } from '@orangecharts/indicator-kit';
|
|
@@ -53,7 +61,14 @@ export interface WrunPackedRunRequest extends WrunPackedRowsBlock {
|
|
|
53
61
|
/** 'live' arms same-bar snapshot/restore replay; 'historical' drives each
|
|
54
62
|
* row exactly once. */
|
|
55
63
|
mode: 'historical' | 'live';
|
|
56
|
-
module
|
|
64
|
+
/** The module's key in the worker's cache (`${sha256}|${abi}`, the handle's
|
|
65
|
+
* `key`): a worker holding it reuses its compiled module. */
|
|
66
|
+
moduleKey: string;
|
|
67
|
+
/** The module's original bytes: the host's private snapshot behind the
|
|
68
|
+
* handle, copied by structured clone (never transferred). The worker
|
|
69
|
+
* compiles them only on a miss (it never held the key, or let it go),
|
|
70
|
+
* after checking they hash to the key's digest. */
|
|
71
|
+
moduleBytes: Uint8Array;
|
|
57
72
|
outputCount: number;
|
|
58
73
|
/** init()'s positional argument block (declared params, in order). */
|
|
59
74
|
initArgs: number[];
|
|
@@ -71,14 +86,67 @@ export interface WrunPackedRunRequest extends WrunPackedRowsBlock {
|
|
|
71
86
|
* a text param with no entry reads as "" at the module. */
|
|
72
87
|
textParams?: Readonly<Record<number, Uint8Array>>;
|
|
73
88
|
}
|
|
89
|
+
/** One import of a module, as WebAssembly.Module.imports() lists it. */
|
|
90
|
+
export interface WrunModuleImport {
|
|
91
|
+
readonly module: string;
|
|
92
|
+
readonly name: string;
|
|
93
|
+
}
|
|
94
|
+
/** A module the engine worker verified and compiled: the client's opaque handle, never a WebAssembly.Module.
|
|
95
|
+
* The host keeps the original bytes privately (a WeakMap behind the handle); nothing outside the host reads them. */
|
|
96
|
+
export interface WrunModuleHandle {
|
|
97
|
+
/** `${sha256}|${abi}`: the worker's cache key. Minted by the worker's verified load, never by a caller. */
|
|
98
|
+
readonly key: string;
|
|
99
|
+
/** Hex sha256 of the ORIGINAL package bytes (the sheet's wasm_sha256 pin when it has one; computed otherwise). */
|
|
100
|
+
readonly sha256: string;
|
|
101
|
+
/** The ABI version the sheet declares (metadata.abi_version). */
|
|
102
|
+
readonly abi: WrunAbiVersion;
|
|
103
|
+
/** Every import in WebAssembly.Module.imports() order (the bar-count and stamp readers). */
|
|
104
|
+
readonly imports: readonly WrunModuleImport[];
|
|
105
|
+
}
|
|
106
|
+
/** A module's key in the engine worker's cache, the handle's `key`: the sha256 of its original bytes and the ABI it
|
|
107
|
+
* compiles for. The worker mints it from the digest it computed; the client keys its own cache of a pinned sheet's
|
|
108
|
+
* handle by the same spelling of the pin, so the two never drift apart. */
|
|
109
|
+
export declare function wrunModuleKey(sha256: string, abi: WrunAbiVersion): string;
|
|
110
|
+
/** main -> worker: hash, verify, prepare and compile a module; cache it under its key. */
|
|
111
|
+
export interface WrunModuleLoadRequest {
|
|
112
|
+
kind: 'module-load';
|
|
113
|
+
id: number;
|
|
114
|
+
abi: WrunAbiVersion;
|
|
115
|
+
/** The sheet's pin; a mismatch answers `module-pin-mismatch` (with the digest found) and caches nothing. */
|
|
116
|
+
sha256Pin?: string;
|
|
117
|
+
/** The original bytes. Copied, never transferred: the host keeps its own snapshot. */
|
|
118
|
+
bytes: Uint8Array;
|
|
119
|
+
}
|
|
120
|
+
export interface WrunModuleLoadResponse {
|
|
121
|
+
id: number;
|
|
122
|
+
ok: true;
|
|
123
|
+
kind: 'module-load';
|
|
124
|
+
key: string;
|
|
125
|
+
sha256: string;
|
|
126
|
+
imports: WrunModuleImport[];
|
|
127
|
+
}
|
|
128
|
+
/** worker -> main, once per run, live-start and live-rows request, once the module is instantiated, right before the
|
|
129
|
+
* guest's first call (or at once for live-rows): the run deadline starts. A terminal reply may come without it (a
|
|
130
|
+
* lost session, a refused load). */
|
|
131
|
+
export interface WrunWorkerRunningMessage {
|
|
132
|
+
id: number;
|
|
133
|
+
running: true;
|
|
134
|
+
}
|
|
135
|
+
/** A full run as the ABI host runs it (`runWrunPackedRequest`): the wire request minus the module's transport (its
|
|
136
|
+
* key and bytes) plus the module the engine worker resolved them to. An internal type the worker's handler builds;
|
|
137
|
+
* the wire type never carries a module. */
|
|
138
|
+
export type WrunResolvedRunRequest = Omit<WrunPackedRunRequest, 'moduleKey' | 'moduleBytes'> & {
|
|
139
|
+
module: WebAssembly.Module;
|
|
140
|
+
};
|
|
74
141
|
/** Full run that also OPENS (or replaces) a live session under sessionKey. */
|
|
75
142
|
export interface WrunLiveStartRequest extends WrunPackedRunRequest {
|
|
76
143
|
kind: 'live-start';
|
|
77
144
|
sessionKey: string;
|
|
78
145
|
/** The live context generation opening this session. The worker keeps the
|
|
79
146
|
* newest epoch per session key: a live-start whose epoch is no longer the
|
|
80
|
-
* newest when its instantiation
|
|
81
|
-
* arrived meanwhile
|
|
147
|
+
* newest when its compile and instantiation settle (a newer start or a
|
|
148
|
+
* live-end arrived meanwhile; the worker reads the fence and the epoch as
|
|
149
|
+
* the start arrives) computes its block but installs no session, so a
|
|
82
150
|
* torn-down overlay's pending start can never resurrect a session. Absent
|
|
83
151
|
* on legacy callers: installs unconditionally after the live-end fence. */
|
|
84
152
|
epoch?: number;
|
|
@@ -130,7 +198,7 @@ export interface WrunLiveEndRequest {
|
|
|
130
198
|
}
|
|
131
199
|
/** Everything the sandbox worker accepts. A bare WrunPackedRunRequest (no
|
|
132
200
|
* `kind`) stays the classic one-shot run. */
|
|
133
|
-
export type WrunWorkerRequest = WrunPackedRunRequest | WrunLiveStartRequest | WrunLiveRowsRequest | WrunLiveEndRequest;
|
|
201
|
+
export type WrunWorkerRequest = WrunPackedRunRequest | WrunLiveStartRequest | WrunLiveRowsRequest | WrunLiveEndRequest | WrunModuleLoadRequest;
|
|
134
202
|
interface WrunPackedRunStrings {
|
|
135
203
|
lens: Int32Array;
|
|
136
204
|
offsets: Int32Array;
|
|
@@ -157,7 +225,7 @@ export type WrunWorkerResponse = {
|
|
|
157
225
|
frames?: (string | undefined)[];
|
|
158
226
|
/** Live-mode blocks only: the block's restore/snapshot accounting. */
|
|
159
227
|
live?: WrunLiveBlockStats;
|
|
160
|
-
} | {
|
|
228
|
+
} | WrunModuleLoadResponse | WrunWorkerRunningMessage | {
|
|
161
229
|
id: number;
|
|
162
230
|
ok: false;
|
|
163
231
|
error: string;
|
|
@@ -165,11 +233,18 @@ export type WrunWorkerResponse = {
|
|
|
165
233
|
* started, disposed, or lost to a worker respawn). The caller rebuilds
|
|
166
234
|
* via a fresh live-start instead of treating this as a compute error. */
|
|
167
235
|
sessionLost?: true;
|
|
168
|
-
/** live-rows only: the block was refused before
|
|
169
|
-
* rows run backwards (WrunLiveOrderError); the
|
|
170
|
-
* the caller reseeds it from its buffers (the
|
|
171
|
-
* disagree on the watermark) instead of retrying
|
|
172
|
-
|
|
236
|
+
/** `live-order` (live-rows only): the block was refused before
|
|
237
|
+
* evaluation because its rows run backwards (WrunLiveOrderError); the
|
|
238
|
+
* session survives, and the caller reseeds it from its buffers (the
|
|
239
|
+
* worker and the context disagree on the watermark) instead of retrying
|
|
240
|
+
* the same block. `module-pin-mismatch`: the bytes do not hash to the
|
|
241
|
+
* sheet's pin (a load) or to the run's module key (a full run or
|
|
242
|
+
* live-start compiling on a miss); nothing is cached. `module-compile-
|
|
243
|
+
* failed`: the engine refused to compile the module (a
|
|
244
|
+
* WebAssembly.CompileError); nothing is cached. */
|
|
245
|
+
code?: 'live-order' | 'module-pin-mismatch' | 'module-compile-failed';
|
|
246
|
+
/** `module-pin-mismatch` only: the hex sha256 the bytes hash to. */
|
|
247
|
+
sha256?: string;
|
|
173
248
|
};
|
|
174
249
|
/** One unpacked result row: `outputs` is null on a non-ready row; `strings`
|
|
175
250
|
* entries are undefined for ABSENT slots and '' for present-empty writes. */
|
|
@@ -14,9 +14,17 @@
|
|
|
14
14
|
* when string slots are declared.
|
|
15
15
|
* - Response: `ready` (Uint8Array) + `outputs` (Float64Array, row-major at
|
|
16
16
|
* the output count), plus the packed string table when slots are declared.
|
|
17
|
-
* - Every buffer is transferred, never structured-cloned
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* - Every row and output buffer is transferred, never structured-cloned.
|
|
18
|
+
* - The module crosses as its original BYTES, never as a compiled
|
|
19
|
+
* `WebAssembly.Module` (the shared engine protocol, wrun-chart-host 0.6.0):
|
|
20
|
+
* `module-load` hands the worker the bytes once to hash, verify against the
|
|
21
|
+
* sheet's pin, clamp, prepare and compile, and answers the client's opaque
|
|
22
|
+
* handle (`WrunModuleHandle`); every full run and live-start names the
|
|
23
|
+
* compiled module by its key and carries the bytes again (copied by
|
|
24
|
+
* structured clone, never transferred), so a worker that lost its cache
|
|
25
|
+
* (a respawn, an eviction) compiles them again. The worker answers
|
|
26
|
+
* `{ id, running: true }` once the module is instantiated (the request
|
|
27
|
+
* executes from there), and the run's deadline starts there.
|
|
20
28
|
*/
|
|
21
29
|
const WRUN_ABI_ORDER = {
|
|
22
30
|
'wrun-1': 1,
|
|
@@ -29,6 +37,12 @@ const WRUN_ABI_ORDER = {
|
|
|
29
37
|
export function abiAtLeast(abi, floor) {
|
|
30
38
|
return WRUN_ABI_ORDER[abi] >= WRUN_ABI_ORDER[floor];
|
|
31
39
|
}
|
|
40
|
+
/** A module's key in the engine worker's cache, the handle's `key`: the sha256 of its original bytes and the ABI it
|
|
41
|
+
* compiles for. The worker mints it from the digest it computed; the client keys its own cache of a pinned sheet's
|
|
42
|
+
* handle by the same spelling of the pin, so the two never drift apart. */
|
|
43
|
+
export function wrunModuleKey(sha256, abi) {
|
|
44
|
+
return `${sha256}|${abi}`;
|
|
45
|
+
}
|
|
32
46
|
/** A live rows block was refused BEFORE any evaluation because its rows run
|
|
33
47
|
* backwards relative to the session watermark (or each other). The guest
|
|
34
48
|
* state is untouched: the session stays valid, so the worker answers a
|
|
@@ -161,7 +161,8 @@ export declare function marketDataAttestationRenewBy(venue: MarketDataVenue, att
|
|
|
161
161
|
export declare function isMarketDataAgreementCurrent(venue: MarketDataVenue, agreement: MarketDataAgreement | null | undefined): boolean;
|
|
162
162
|
/**
|
|
163
163
|
* Normalized checkout outcome. 'redirect' = leave for Stripe. 'refused' = the server declined (or the store answered a
|
|
164
|
-
* professional account itself); 'professional_unavailable'
|
|
164
|
+
* professional account itself); 'professional_unavailable' ends the purchase until a later non-professional declaration,
|
|
165
|
+
* never a re-price. 'busy' = a checkout is
|
|
165
166
|
* already in flight, or the guest wall took the click.
|
|
166
167
|
*/
|
|
167
168
|
export type MarketDataCheckoutResult = {
|
|
@@ -726,6 +726,13 @@ const METRIC_PROFILE_FIELDS = [
|
|
|
726
726
|
['deltaLayout', PREFERENCE],
|
|
727
727
|
['levelBasis', PREFERENCE],
|
|
728
728
|
];
|
|
729
|
+
/**
|
|
730
|
+
* The Symbol Comparison overlays (new price scale, same % scale, new pane): the name the user gave the series (`label`,
|
|
731
|
+
* the settings dialogs' Label row, web comparison-series-display.util) is instance state like its symbol. The row
|
|
732
|
+
* keeps it; a template or a saved default never renames another series. Scoped to the three types: the name is
|
|
733
|
+
* generic, and declared for every overlay it would start persisting other natives' engine keys.
|
|
734
|
+
*/
|
|
735
|
+
const SYMBOL_COMPARISON_FIELDS = [['label', INSTANCE]];
|
|
729
736
|
/**
|
|
730
737
|
* The fields one indicator type declares beyond INDICATOR_COMMON_FIELDS: a row here adds a key, or replaces the shared
|
|
731
738
|
* row of the same owner and key.
|
|
@@ -742,6 +749,9 @@ export const INDICATOR_TYPE_FIELDS = {
|
|
|
742
749
|
DELTA_PROFILE: [['profileWindow', PREFERENCE]],
|
|
743
750
|
OPEN_INTEREST_PROFILE: METRIC_PROFILE_FIELDS,
|
|
744
751
|
LIQUIDATION_PROFILE: METRIC_PROFILE_FIELDS,
|
|
752
|
+
SYMBOL_COMPARISON_SCALE: SYMBOL_COMPARISON_FIELDS,
|
|
753
|
+
SYMBOL_COMPARISON_PCT_SCALE: SYMBOL_COMPARISON_FIELDS,
|
|
754
|
+
SYMBOL_COMPARISON_PANE: SYMBOL_COMPARISON_FIELDS,
|
|
745
755
|
/** Margin Rates derives `multipleStyles` (a style row per source) from its own sources: never carried onto another row. */
|
|
746
756
|
MARGIN_RATES: [['multipleStyles', META_DERIVED]],
|
|
747
757
|
// The meta preferences the settings dialogs write (TEMPLATES-PLAN decision 6): template-lane.
|
|
@@ -3,3 +3,15 @@ export declare function getChartMountEpoch(): number;
|
|
|
3
3
|
export declare function bumpChartMountEpoch(): number;
|
|
4
4
|
/** Captures the epoch now; the returned check reads false once a workspace switch moved it. */
|
|
5
5
|
export declare function captureMountEpochOwner(): () => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Resolves once `owner` (a `captureMountEpochOwner` check) reads stale: at
|
|
8
|
+
* once when it already does, else at the bump that moves the epoch. A loop
|
|
9
|
+
* that awaits pane inits races it, so a mount a newer click cancelled returns
|
|
10
|
+
* at the cancel point instead of waiting out inits that build nothing
|
|
11
|
+
* (`mountWorkspaceCharts` in chart-area-bridge.util). `stop` drops the wait
|
|
12
|
+
* once the loop is done.
|
|
13
|
+
*/
|
|
14
|
+
export declare function whenMountEpochStale(owner: () => boolean): {
|
|
15
|
+
stale: Promise<void>;
|
|
16
|
+
stop: () => void;
|
|
17
|
+
};
|
|
@@ -14,12 +14,16 @@
|
|
|
14
14
|
* importing titan-charts (which re-exports both functions for its callers).
|
|
15
15
|
*/
|
|
16
16
|
let chartMountEpoch = 0;
|
|
17
|
+
/** The waits raced against the epoch (`whenMountEpochStale`), woken at every bump. */
|
|
18
|
+
const bumpListeners = new Set();
|
|
17
19
|
export function getChartMountEpoch() {
|
|
18
20
|
return chartMountEpoch;
|
|
19
21
|
}
|
|
20
22
|
/** Makes every run or continuation that captured the epoch before this call stale at its next check. */
|
|
21
23
|
export function bumpChartMountEpoch() {
|
|
22
24
|
chartMountEpoch += 1;
|
|
25
|
+
for (const listener of [...bumpListeners])
|
|
26
|
+
listener();
|
|
23
27
|
return chartMountEpoch;
|
|
24
28
|
}
|
|
25
29
|
/** Captures the epoch now; the returned check reads false once a workspace switch moved it. */
|
|
@@ -27,3 +31,31 @@ export function captureMountEpochOwner() {
|
|
|
27
31
|
const epoch = chartMountEpoch;
|
|
28
32
|
return () => epoch === chartMountEpoch;
|
|
29
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolves once `owner` (a `captureMountEpochOwner` check) reads stale: at
|
|
36
|
+
* once when it already does, else at the bump that moves the epoch. A loop
|
|
37
|
+
* that awaits pane inits races it, so a mount a newer click cancelled returns
|
|
38
|
+
* at the cancel point instead of waiting out inits that build nothing
|
|
39
|
+
* (`mountWorkspaceCharts` in chart-area-bridge.util). `stop` drops the wait
|
|
40
|
+
* once the loop is done.
|
|
41
|
+
*/
|
|
42
|
+
export function whenMountEpochStale(owner) {
|
|
43
|
+
if (!owner())
|
|
44
|
+
return { stale: Promise.resolve(), stop: () => undefined };
|
|
45
|
+
let listener = () => undefined;
|
|
46
|
+
const stale = new Promise((resolve) => {
|
|
47
|
+
listener = () => {
|
|
48
|
+
if (owner())
|
|
49
|
+
return;
|
|
50
|
+
bumpListeners.delete(listener);
|
|
51
|
+
resolve();
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
bumpListeners.add(listener);
|
|
55
|
+
return {
|
|
56
|
+
stale,
|
|
57
|
+
stop: () => {
|
|
58
|
+
bumpListeners.delete(listener);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CRYPTOCAP: the venue of the crypto-wide indices and dominance series (BTC.D, TOTAL, TOTAL2, OTHERS.D, ...; see
|
|
3
|
+
* docs/features/data/cryptocap-indices.md). The backend prints each series as raw CRYPTO_DOMINANCE points and serves
|
|
4
|
+
* its candles as CRYPTO_DOMINANCE_AGG on tsdb-gateway v2: value candles with no volume, trades or book behind them.
|
|
5
|
+
*
|
|
6
|
+
* A leaf on purpose, with no imports: the market-kind table (`marketKind.util`) and the ticker hub and the sub-minute
|
|
7
|
+
* block (`index-mode.util`) both read this list, and neither may call into the other at module load. Web code asks
|
|
8
|
+
* `checkIsCryptoIndex` here, never through `index-mode.util` or `marketKind.util`: over a hundred specs mock those two
|
|
9
|
+
* with partial factories, and a predicate read through such a mock throws.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CRYPTO_INDEX_EXCHANGES: readonly ["CRYPTOCAP"];
|
|
12
|
+
/**
|
|
13
|
+
* A crypto index venue (`CRYPTO_INDEX_EXCHANGES`), the `'cryptoIndex'` market kind. Case-insensitive like the kind
|
|
14
|
+
* table, and a foreign shape (a persisted object, a number) is no venue, never a throw.
|
|
15
|
+
*/
|
|
16
|
+
export declare function checkIsCryptoIndex(exchange: string | undefined | null): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CRYPTOCAP: the venue of the crypto-wide indices and dominance series (BTC.D, TOTAL, TOTAL2, OTHERS.D, ...; see
|
|
3
|
+
* docs/features/data/cryptocap-indices.md). The backend prints each series as raw CRYPTO_DOMINANCE points and serves
|
|
4
|
+
* its candles as CRYPTO_DOMINANCE_AGG on tsdb-gateway v2: value candles with no volume, trades or book behind them.
|
|
5
|
+
*
|
|
6
|
+
* A leaf on purpose, with no imports: the market-kind table (`marketKind.util`) and the ticker hub and the sub-minute
|
|
7
|
+
* block (`index-mode.util`) both read this list, and neither may call into the other at module load. Web code asks
|
|
8
|
+
* `checkIsCryptoIndex` here, never through `index-mode.util` or `marketKind.util`: over a hundred specs mock those two
|
|
9
|
+
* with partial factories, and a predicate read through such a mock throws.
|
|
10
|
+
*/
|
|
11
|
+
export const CRYPTO_INDEX_EXCHANGES = ['CRYPTOCAP'];
|
|
12
|
+
const CRYPTO_INDEX_EXCHANGES_SET = new Set(CRYPTO_INDEX_EXCHANGES);
|
|
13
|
+
/**
|
|
14
|
+
* A crypto index venue (`CRYPTO_INDEX_EXCHANGES`), the `'cryptoIndex'` market kind. Case-insensitive like the kind
|
|
15
|
+
* table, and a foreign shape (a persisted object, a number) is no venue, never a throw.
|
|
16
|
+
*/
|
|
17
|
+
export function checkIsCryptoIndex(exchange) {
|
|
18
|
+
return typeof exchange === 'string' && CRYPTO_INDEX_EXCHANGES_SET.has(exchange.toUpperCase());
|
|
19
|
+
}
|
|
@@ -14,11 +14,14 @@
|
|
|
14
14
|
* Two market facts narrow it for a browser-run Indicator's lanes (`wrunLaneServiceOnMarket`):
|
|
15
15
|
* - the market-kind table: forex and commodities trade no volume the chart can split, keep no
|
|
16
16
|
* book and list no options, so they serve no volume profile, buy/sell volume, order book,
|
|
17
|
-
* implied volatility or skew, whatever the index-mode admission lets through;
|
|
17
|
+
* implied volatility or skew, whatever the index-mode admission lets through; a crypto index
|
|
18
|
+
* (CRYPTOCAP, not index-mode: it fetches by period like crypto) serves its value candles and no
|
|
19
|
+
* other lane at all;
|
|
18
20
|
* - the coin table: the option-summary lanes (implied volatility, skew) hold a series for the
|
|
19
21
|
* coins `WRUN_OPTION_SUMMARY_COINS` lists (BTC and ETH) and no other.
|
|
20
22
|
* The dispatcher's own admission (`isKScriptTypeServedOnIndexMode`) stays as it is.
|
|
21
23
|
*/
|
|
24
|
+
import { checkIsCryptoIndex } from './crypto-index.leaf.js';
|
|
22
25
|
import { checkIsIndexMode } from './index-mode.util.js';
|
|
23
26
|
import { checkIsForexOrCommodity } from './marketKind.util.js';
|
|
24
27
|
import { WRUN_OPTION_SUMMARY_COINS, WRUN_OPTION_SUMMARY_LANES } from '../wrun/wrun-option-summary-lane.util.js';
|
|
@@ -34,6 +37,8 @@ const FOREX_COMMODITY_UNSERVED_TYPES = new Set([
|
|
|
34
37
|
WRUN_OPTION_SUMMARY_LANES.implied_volatility.type,
|
|
35
38
|
WRUN_OPTION_SUMMARY_LANES.skew.type,
|
|
36
39
|
]);
|
|
40
|
+
/** The one lane fetch type a crypto index market serves (the market-kind table): its value candles. */
|
|
41
|
+
const CRYPTO_INDEX_SERVED_TYPES = new Set(['ohlcv']);
|
|
37
42
|
/** The lane fetch types served for some coins only, and those coins (the coin table). */
|
|
38
43
|
const COIN_SERVED_TYPES = Object.freeze({
|
|
39
44
|
[WRUN_OPTION_SUMMARY_LANES.implied_volatility.type]: WRUN_OPTION_SUMMARY_COINS,
|
|
@@ -55,6 +60,9 @@ export function wrunLaneServiceOnMarket({ type, exchange, coin, nativeRows, }) {
|
|
|
55
60
|
if (FOREX_COMMODITY_UNSERVED_TYPES.has(type) && checkIsForexOrCommodity(exchange)) {
|
|
56
61
|
return { served: false, reason: 'market-kind' };
|
|
57
62
|
}
|
|
63
|
+
if (!CRYPTO_INDEX_SERVED_TYPES.has(type) && checkIsCryptoIndex(exchange)) {
|
|
64
|
+
return { served: false, reason: 'market-kind' };
|
|
65
|
+
}
|
|
58
66
|
const coins = COIN_SERVED_TYPES[type];
|
|
59
67
|
const word = typeof coin === 'string' ? coin.trim().toUpperCase() : '';
|
|
60
68
|
if (coins !== undefined && word !== '' && !coins.includes(word))
|
|
@@ -55,11 +55,17 @@ export declare function checkIsIndexMode(exchange: string | undefined): boolean;
|
|
|
55
55
|
/** An index venue (`INDEX_VENUE_EXCHANGES`): a quote series on the US session grid. */
|
|
56
56
|
export declare function checkIsIndexVenue(exchange: string | undefined): boolean;
|
|
57
57
|
/**
|
|
58
|
-
* Exchanges that
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
58
|
+
* Exchanges that print quotes instead of trades: value-only candles with no
|
|
59
|
+
* volume and a quote channel live (forex, commodity and the index venues on
|
|
60
|
+
* TICKER/TICKER_AGG, the crypto indices on CRYPTO_DOMINANCE/CRYPTO_DOMINANCE_AGG).
|
|
61
|
+
* The hub of the quote routing: the candle parse (the ohlcv and K_OHLCV
|
|
62
|
+
* workers keep a volume-less row), the sided-candle refusal and the live
|
|
63
|
+
* channel (`liveQuoteType`, live-feed-channel-factory.util) all read it; the
|
|
64
|
+
* wire candle Type follows `seriesDomainOf` (V2_CANDLE_TYPE). Governed CME
|
|
65
|
+
* needs no carve-out here: the flag-dependent kind already classifies it
|
|
66
|
+
* futures (TRADE data) with the release gate on and commodity (TICKER,
|
|
67
|
+
* fail-closed) with it off; both states are pinned by
|
|
68
|
+
* cme-futures-capability.spec.ts.
|
|
63
69
|
*/
|
|
64
70
|
export declare function checkIsTickerDataType(exchange: string | undefined): boolean;
|
|
65
71
|
export declare function checkIsBlockedOn1s(exchange: string | undefined): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { formatDisplayToExchange } from '../exchange-normalization.util.js';
|
|
2
|
+
import { CRYPTO_INDEX_EXCHANGES, checkIsCryptoIndex } from './crypto-index.leaf.js';
|
|
2
3
|
import { PREDICTION_MARKET_EXCHANGE_NAMES } from './prediction-identity.util.js';
|
|
3
4
|
// ============================================================================
|
|
4
5
|
// EXCHANGE CONSTANTS
|
|
@@ -48,10 +49,15 @@ const INDEX_MODE_EXCHANGES = [
|
|
|
48
49
|
...COMMODITY_EXCHANGES,
|
|
49
50
|
...INDEX_VENUE_EXCHANGES,
|
|
50
51
|
];
|
|
51
|
-
// Exchanges that don't support 1s interval (index mode + prediction + forex + commodity
|
|
52
|
-
// Prediction venues poll a price rather than printing trades, so none of them can
|
|
53
|
-
// host a 1s bar
|
|
54
|
-
|
|
52
|
+
// Exchanges that don't support 1s interval (index mode + prediction + forex + commodity + the
|
|
53
|
+
// crypto indices). Prediction venues poll a price rather than printing trades, so none of them can
|
|
54
|
+
// host a 1s bar: the list tracks the venue SET, not Polymarket alone. The crypto indices'
|
|
55
|
+
// candle tables start at 1m, so no sub-minute rung is ever served there.
|
|
56
|
+
const EXCHANGES_BLOCKED_ON_1S = [
|
|
57
|
+
...INDEX_MODE_EXCHANGES,
|
|
58
|
+
...PREDICTION_MARKET_EXCHANGE_NAMES,
|
|
59
|
+
...CRYPTO_INDEX_EXCHANGES,
|
|
60
|
+
];
|
|
55
61
|
const PM_SIGNAL_CRYPTO_SYMBOLS = ['BTC', 'ETH', 'SOL', 'XRP'];
|
|
56
62
|
const PM_SIGNAL_TRADFI_SYMBOLS = [
|
|
57
63
|
'TSLA',
|
|
@@ -315,14 +321,20 @@ export function checkIsIndexVenue(exchange) {
|
|
|
315
321
|
return checkIsExchangeInSet(exchange, INDEX_VENUE_EXCHANGES_SET);
|
|
316
322
|
}
|
|
317
323
|
/**
|
|
318
|
-
* Exchanges that
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
324
|
+
* Exchanges that print quotes instead of trades: value-only candles with no
|
|
325
|
+
* volume and a quote channel live (forex, commodity and the index venues on
|
|
326
|
+
* TICKER/TICKER_AGG, the crypto indices on CRYPTO_DOMINANCE/CRYPTO_DOMINANCE_AGG).
|
|
327
|
+
* The hub of the quote routing: the candle parse (the ohlcv and K_OHLCV
|
|
328
|
+
* workers keep a volume-less row), the sided-candle refusal and the live
|
|
329
|
+
* channel (`liveQuoteType`, live-feed-channel-factory.util) all read it; the
|
|
330
|
+
* wire candle Type follows `seriesDomainOf` (V2_CANDLE_TYPE). Governed CME
|
|
331
|
+
* needs no carve-out here: the flag-dependent kind already classifies it
|
|
332
|
+
* futures (TRADE data) with the release gate on and commodity (TICKER,
|
|
333
|
+
* fail-closed) with it off; both states are pinned by
|
|
334
|
+
* cme-futures-capability.spec.ts.
|
|
323
335
|
*/
|
|
324
336
|
export function checkIsTickerDataType(exchange) {
|
|
325
|
-
return checkIsForex(exchange) || checkIsCommodity(exchange) || checkIsIndexVenue(exchange);
|
|
337
|
+
return (checkIsForex(exchange) || checkIsCommodity(exchange) || checkIsIndexVenue(exchange) || checkIsCryptoIndex(exchange));
|
|
326
338
|
}
|
|
327
339
|
export function checkIsBlockedOn1s(exchange) {
|
|
328
340
|
if (isCmeFuturesPolicyActive(exchange))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The source answer budget: the most one kScript source answer may hold, in bytes at 8 per numeric cell (the row
|
|
3
|
+
* cache's estimate, `estimateKScriptSourceRowsBytes`). It is the one size limit every layer a source answer crosses
|
|
4
|
+
* reads, so the layers cannot disagree again (OPTFLOW-HANG, field dump 2026-10-20 17:50 SGT):
|
|
5
|
+
*
|
|
6
|
+
* - the row lanes plan their asks to fit it (`rowBudget`, wrun-row-lanes.util `wrunRowLaneMaxRows`): the newest bars
|
|
7
|
+
* whose projected rows fit are read, every older asked bar is partial;
|
|
8
|
+
* - a worker twin that holds its own row cap fails an answer past the CEILING loudly (never truncated);
|
|
9
|
+
* - the source row cache keeps an answer up to the ceiling, so a planned answer is always kept and a rerun (the
|
|
10
|
+
* source ladder's rung, a remount, a lazy refresh) reads it instead of asking the wire again;
|
|
11
|
+
* - the source fetch boundary rings `kscript-source-answer-over-budget` for an answer past the budget, and the dump's
|
|
12
|
+
* `sourceAnswerOverBudget` verdict counts them.
|
|
13
|
+
*
|
|
14
|
+
* The field case it closes: SPY 1h with Premium by Strike and Strike Footprint. The contract flow lane sized each ask
|
|
15
|
+
* by the worker's 500,000-row failure cap (about 25 MB on the wire, 25 s), past the lane's own deadline (10.6 s for
|
|
16
|
+
* 252 bars) and the row cache's 8 MiB entry cap: the lane degraded before the answer landed, the cache refused the
|
|
17
|
+
* late answer, the source ladder asked again, and neither indicator painted. Each answer that landed crossed to the
|
|
18
|
+
* page as one structured clone of about 400,000 nested arrays (2.7 s on the main thread).
|
|
19
|
+
*
|
|
20
|
+
* Why 8 MiB: the cache's entry cap before this budget existed, and about 1.6 MB on the wire for SPY's contract flow
|
|
21
|
+
* (measured 2026-10-20 on INT: about 35 bytes a row), answered in 2 to 5 s, inside the lane deadline's 10 s floor.
|
|
22
|
+
* Raising it is one edit here: every layer follows. A deeper read needs a smaller answer, not a bigger budget (the
|
|
23
|
+
* per-strike fold, UW-PARITY design/STRIKE-FLOW-SCOPE.md).
|
|
24
|
+
*/
|
|
25
|
+
/** Bytes one numeric cell weighs in every estimate of a source answer. */
|
|
26
|
+
export declare const KSCRIPT_SOURCE_CELL_BYTES = 8;
|
|
27
|
+
/** The bytes a planned source answer stays within. */
|
|
28
|
+
export declare const KSCRIPT_SOURCE_ANSWER_BUDGET_BYTES: number;
|
|
29
|
+
/**
|
|
30
|
+
* The bytes a source answer may reach at all: twice the budget. A plan projects its rows from a measured session; a
|
|
31
|
+
* busier session can land past the budget, and up to the ceiling it is still delivered, cached and rung (flagged);
|
|
32
|
+
* past it a worker twin with its own row cap fails the request by name.
|
|
33
|
+
*/
|
|
34
|
+
export declare const KSCRIPT_SOURCE_ANSWER_CEILING_BYTES: number;
|
|
35
|
+
/** The rows of `cellsPerRow` numeric cells each that fit `bytes` (the budget by default); at least one. */
|
|
36
|
+
export declare function kScriptSourceAnswerRows(cellsPerRow: number, bytes?: number): number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The source answer budget: the most one kScript source answer may hold, in bytes at 8 per numeric cell (the row
|
|
3
|
+
* cache's estimate, `estimateKScriptSourceRowsBytes`). It is the one size limit every layer a source answer crosses
|
|
4
|
+
* reads, so the layers cannot disagree again (OPTFLOW-HANG, field dump 2026-10-20 17:50 SGT):
|
|
5
|
+
*
|
|
6
|
+
* - the row lanes plan their asks to fit it (`rowBudget`, wrun-row-lanes.util `wrunRowLaneMaxRows`): the newest bars
|
|
7
|
+
* whose projected rows fit are read, every older asked bar is partial;
|
|
8
|
+
* - a worker twin that holds its own row cap fails an answer past the CEILING loudly (never truncated);
|
|
9
|
+
* - the source row cache keeps an answer up to the ceiling, so a planned answer is always kept and a rerun (the
|
|
10
|
+
* source ladder's rung, a remount, a lazy refresh) reads it instead of asking the wire again;
|
|
11
|
+
* - the source fetch boundary rings `kscript-source-answer-over-budget` for an answer past the budget, and the dump's
|
|
12
|
+
* `sourceAnswerOverBudget` verdict counts them.
|
|
13
|
+
*
|
|
14
|
+
* The field case it closes: SPY 1h with Premium by Strike and Strike Footprint. The contract flow lane sized each ask
|
|
15
|
+
* by the worker's 500,000-row failure cap (about 25 MB on the wire, 25 s), past the lane's own deadline (10.6 s for
|
|
16
|
+
* 252 bars) and the row cache's 8 MiB entry cap: the lane degraded before the answer landed, the cache refused the
|
|
17
|
+
* late answer, the source ladder asked again, and neither indicator painted. Each answer that landed crossed to the
|
|
18
|
+
* page as one structured clone of about 400,000 nested arrays (2.7 s on the main thread).
|
|
19
|
+
*
|
|
20
|
+
* Why 8 MiB: the cache's entry cap before this budget existed, and about 1.6 MB on the wire for SPY's contract flow
|
|
21
|
+
* (measured 2026-10-20 on INT: about 35 bytes a row), answered in 2 to 5 s, inside the lane deadline's 10 s floor.
|
|
22
|
+
* Raising it is one edit here: every layer follows. A deeper read needs a smaller answer, not a bigger budget (the
|
|
23
|
+
* per-strike fold, UW-PARITY design/STRIKE-FLOW-SCOPE.md).
|
|
24
|
+
*/
|
|
25
|
+
/** Bytes one numeric cell weighs in every estimate of a source answer. */
|
|
26
|
+
export const KSCRIPT_SOURCE_CELL_BYTES = 8;
|
|
27
|
+
/** The bytes a planned source answer stays within. */
|
|
28
|
+
export const KSCRIPT_SOURCE_ANSWER_BUDGET_BYTES = 8 * 1024 * 1024;
|
|
29
|
+
/**
|
|
30
|
+
* The bytes a source answer may reach at all: twice the budget. A plan projects its rows from a measured session; a
|
|
31
|
+
* busier session can land past the budget, and up to the ceiling it is still delivered, cached and rung (flagged);
|
|
32
|
+
* past it a worker twin with its own row cap fails the request by name.
|
|
33
|
+
*/
|
|
34
|
+
export const KSCRIPT_SOURCE_ANSWER_CEILING_BYTES = 2 * KSCRIPT_SOURCE_ANSWER_BUDGET_BYTES;
|
|
35
|
+
/** The rows of `cellsPerRow` numeric cells each that fit `bytes` (the budget by default); at least one. */
|
|
36
|
+
export function kScriptSourceAnswerRows(cellsPerRow, bytes = KSCRIPT_SOURCE_ANSWER_BUDGET_BYTES) {
|
|
37
|
+
const width = Number.isFinite(cellsPerRow) && cellsPerRow >= 1 ? Math.floor(cellsPerRow) : 1;
|
|
38
|
+
return Math.max(1, Math.floor(bytes / (width * KSCRIPT_SOURCE_CELL_BYTES)));
|
|
39
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A secondary source's retry and budget numbers (a leaf of utility/chart/kscript-source-degrade.util.ts;
|
|
3
|
-
* P2/inventory.md section 1.1): the constants recovery reads
|
|
3
|
+
* P2/inventory.md section 1.1): the constants recovery reads, the budget the executor reads and the send anchor both
|
|
4
|
+
* source lanes (the kScript engine proxy, the wrun run's lanes) count it from. The degrade registry and
|
|
4
5
|
* its mutators stay in the old module (the chart store and the engine manager share it) behind the chart-host members
|
|
5
6
|
* `chart.markSourcesTerminal`, `chart.markSourceDegraded` and the rest; this leaf holds no state, so it moves into the
|
|
6
7
|
* chart-host package with the phase 2 closure. The old module re-exports it.
|
|
@@ -21,6 +22,14 @@
|
|
|
21
22
|
* per-overlay registry the legend chip is DERIVED from at the diagnostics
|
|
22
23
|
* choke point (chart.ts setIndicatorDiagnostics), so no diagnostics writer
|
|
23
24
|
* can drop the chip and no writer ever sets it directly.
|
|
25
|
+
*
|
|
26
|
+
* On the wrun lane the budget is a paint deadline and stays the chip's
|
|
27
|
+
* authority: counted from the lane's send (resolveSecondarySourceDeadlineMs),
|
|
28
|
+
* a lane still out at it degrades and the run paints without it,
|
|
29
|
+
* while its read (abandoned, never aborted) is joined or adopted by the next
|
|
30
|
+
* run and the source ladder instead of asked again
|
|
31
|
+
* (wrun/run-schedule/wrun-late-reads.util). The read's own bound is the fetch
|
|
32
|
+
* deadline (wrun-deadline.util WRUN_SOURCE_FETCH_DEADLINE_MS).
|
|
24
33
|
*/
|
|
25
34
|
/**
|
|
26
35
|
* Base budget (the floor). Provisional instrumented SLO (2026-09-03): the
|
|
@@ -50,6 +59,34 @@ export declare function resolveSecondarySourceBudgetMs(window: {
|
|
|
50
59
|
toMs?: number;
|
|
51
60
|
intervalMs?: number;
|
|
52
61
|
}): number;
|
|
62
|
+
/**
|
|
63
|
+
* Absolute cap measured from the moment a source request was asked (the
|
|
64
|
+
* engine proxy's request arrival, a wrun lane's dispatch): the send anchor
|
|
65
|
+
* may move the deadline to send + budget, but never past this, so a request
|
|
66
|
+
* that sits queued on the main thread, behind the socket's open or in the
|
|
67
|
+
* worker's queue (or never goes out) still degrades in bounded time.
|
|
68
|
+
*/
|
|
69
|
+
export declare const KSCRIPT_SECONDARY_SOURCE_DISPATCH_CAP_MS = 60000;
|
|
70
|
+
/**
|
|
71
|
+
* When a secondary source request degrades (on the caller's clock), the one
|
|
72
|
+
* anchor rule the kScript engine lane and the wrun lanes share: the budget
|
|
73
|
+
* counts from the moment the request went to the wire (`dispatchedAtMs`),
|
|
74
|
+
* never past `capMs` from the moment it was asked (`startedAtMs`), and never
|
|
75
|
+
* before the budget counted from the ask (a cap below the budget is lifted to
|
|
76
|
+
* it). A request not on the wire yet (`dispatchedAtMs: null`) waits the cap:
|
|
77
|
+
* the engine proxy's rule once it holds a request. A wrun lane asks this rule
|
|
78
|
+
* only after its first send notice and keeps the budget counted from the
|
|
79
|
+
* dispatch until then (`wrunLaneSendDeadline`), so a transport that never
|
|
80
|
+
* reports its send degrades as it always did. The anchor has no default on
|
|
81
|
+
* purpose: every caller says whether its request is on the wire, so time
|
|
82
|
+
* queued before a reported send never eats the budget.
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolveSecondarySourceDeadlineMs(anchor: {
|
|
85
|
+
startedAtMs: number;
|
|
86
|
+
dispatchedAtMs: number | null;
|
|
87
|
+
budgetMs: number;
|
|
88
|
+
capMs?: number;
|
|
89
|
+
}): number;
|
|
53
90
|
/**
|
|
54
91
|
* Gaps between recovery attempts (each is one forced refetch of the overlay
|
|
55
92
|
* with retryAttempt stamped on the degraded names only): the first fires 15s
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A secondary source's retry and budget numbers (a leaf of utility/chart/kscript-source-degrade.util.ts;
|
|
3
|
-
* P2/inventory.md section 1.1): the constants recovery reads
|
|
3
|
+
* P2/inventory.md section 1.1): the constants recovery reads, the budget the executor reads and the send anchor both
|
|
4
|
+
* source lanes (the kScript engine proxy, the wrun run's lanes) count it from. The degrade registry and
|
|
4
5
|
* its mutators stay in the old module (the chart store and the engine manager share it) behind the chart-host members
|
|
5
6
|
* `chart.markSourcesTerminal`, `chart.markSourceDegraded` and the rest; this leaf holds no state, so it moves into the
|
|
6
7
|
* chart-host package with the phase 2 closure. The old module re-exports it.
|
|
@@ -21,6 +22,14 @@
|
|
|
21
22
|
* per-overlay registry the legend chip is DERIVED from at the diagnostics
|
|
22
23
|
* choke point (chart.ts setIndicatorDiagnostics), so no diagnostics writer
|
|
23
24
|
* can drop the chip and no writer ever sets it directly.
|
|
25
|
+
*
|
|
26
|
+
* On the wrun lane the budget is a paint deadline and stays the chip's
|
|
27
|
+
* authority: counted from the lane's send (resolveSecondarySourceDeadlineMs),
|
|
28
|
+
* a lane still out at it degrades and the run paints without it,
|
|
29
|
+
* while its read (abandoned, never aborted) is joined or adopted by the next
|
|
30
|
+
* run and the source ladder instead of asked again
|
|
31
|
+
* (wrun/run-schedule/wrun-late-reads.util). The read's own bound is the fetch
|
|
32
|
+
* deadline (wrun-deadline.util WRUN_SOURCE_FETCH_DEADLINE_MS).
|
|
24
33
|
*/
|
|
25
34
|
/**
|
|
26
35
|
* Base budget (the floor). Provisional instrumented SLO (2026-09-03): the
|
|
@@ -55,6 +64,35 @@ export function resolveSecondarySourceBudgetMs(window) {
|
|
|
55
64
|
const scaled = KSCRIPT_SECONDARY_SOURCE_BUDGET_MS + (rows / 1000) * KSCRIPT_SECONDARY_SOURCE_BUDGET_PER_1K_ROWS_MS;
|
|
56
65
|
return Math.round(Math.min(KSCRIPT_SECONDARY_SOURCE_BUDGET_MAX_MS, Math.max(KSCRIPT_SECONDARY_SOURCE_BUDGET_MS, scaled)));
|
|
57
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Absolute cap measured from the moment a source request was asked (the
|
|
69
|
+
* engine proxy's request arrival, a wrun lane's dispatch): the send anchor
|
|
70
|
+
* may move the deadline to send + budget, but never past this, so a request
|
|
71
|
+
* that sits queued on the main thread, behind the socket's open or in the
|
|
72
|
+
* worker's queue (or never goes out) still degrades in bounded time.
|
|
73
|
+
*/
|
|
74
|
+
export const KSCRIPT_SECONDARY_SOURCE_DISPATCH_CAP_MS = 60_000;
|
|
75
|
+
/**
|
|
76
|
+
* When a secondary source request degrades (on the caller's clock), the one
|
|
77
|
+
* anchor rule the kScript engine lane and the wrun lanes share: the budget
|
|
78
|
+
* counts from the moment the request went to the wire (`dispatchedAtMs`),
|
|
79
|
+
* never past `capMs` from the moment it was asked (`startedAtMs`), and never
|
|
80
|
+
* before the budget counted from the ask (a cap below the budget is lifted to
|
|
81
|
+
* it). A request not on the wire yet (`dispatchedAtMs: null`) waits the cap:
|
|
82
|
+
* the engine proxy's rule once it holds a request. A wrun lane asks this rule
|
|
83
|
+
* only after its first send notice and keeps the budget counted from the
|
|
84
|
+
* dispatch until then (`wrunLaneSendDeadline`), so a transport that never
|
|
85
|
+
* reports its send degrades as it always did. The anchor has no default on
|
|
86
|
+
* purpose: every caller says whether its request is on the wire, so time
|
|
87
|
+
* queued before a reported send never eats the budget.
|
|
88
|
+
*/
|
|
89
|
+
export function resolveSecondarySourceDeadlineMs(anchor) {
|
|
90
|
+
const { startedAtMs, dispatchedAtMs, budgetMs, capMs = KSCRIPT_SECONDARY_SOURCE_DISPATCH_CAP_MS } = anchor;
|
|
91
|
+
const cappedAtMs = startedAtMs + Math.max(budgetMs, capMs);
|
|
92
|
+
if (dispatchedAtMs === null)
|
|
93
|
+
return cappedAtMs;
|
|
94
|
+
return Math.min(cappedAtMs, Math.max(startedAtMs, dispatchedAtMs) + budgetMs);
|
|
95
|
+
}
|
|
58
96
|
/**
|
|
59
97
|
* Gaps between recovery attempts (each is one forced refetch of the overlay
|
|
60
98
|
* with retryAttempt stamped on the degraded names only): the first fires 15s
|