@orangecharts/wrun-chart-host 0.6.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 +13 -5
- package/dist/constants/marketCapabilities.constants.d.ts +5 -0
- package/dist/constants/marketCapabilities.constants.js +16 -0
- package/dist/host-ports.types.d.ts +35 -3
- package/dist/index.d.ts +11 -1
- package/dist/index.js +11 -1
- package/dist/indicators/controls/tpo-session.util.js +42 -18
- package/dist/market-data/billing.interface.d.ts +2 -1
- package/dist/settings-templates/indicator-fields.js +10 -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-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 +26 -18
- package/dist/utility/wrun/wrun-host.service.js +49 -52
- 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-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 +18 -3
- 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 +50 -6
- package/dist/utility/wrun/wrun-overlay-run.util.js +816 -243
- 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-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-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/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
|
@@ -42,6 +42,15 @@ const WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_NAMES = Object.freeze({
|
|
|
42
42
|
export function isWrunOptionsChainCryptoVenueWord(word) {
|
|
43
43
|
return Object.prototype.hasOwnProperty.call(WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS, word);
|
|
44
44
|
}
|
|
45
|
+
/** The name a venue the crypto-options gate keeps dark for a guest goes by in a refusal, by its venue table id (a
|
|
46
|
+
* crypto venue word's row: every plain venue but Deribit); undefined for a venue the gate never darkens (Deribit,
|
|
47
|
+
* CME, OPRA). A chain class naming venues by another word than the decision's (`options_flow`'s `venue` knob names
|
|
48
|
+
* the venue's exchange) reads the gate off this one table. */
|
|
49
|
+
export function wrunOptionsChainGatedVenueName(venueId) {
|
|
50
|
+
const words = Object.keys(WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS);
|
|
51
|
+
const word = words.find((candidate) => WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_IDS[candidate] === venueId);
|
|
52
|
+
return word === undefined ? undefined : WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_NAMES[word];
|
|
53
|
+
}
|
|
45
54
|
/** The venue knob's words spelled for a refusal: `"deribit", "cme", ... or "derive"`. */
|
|
46
55
|
const WRUN_OPTIONS_CHAIN_PINNED_VENUE_WORDS = (() => {
|
|
47
56
|
const spelled = WRUN_OPTIONS_CHAIN_VENUES.filter((word) => word !== 'auto').map((word) => `"${word}"`);
|
|
@@ -262,6 +271,22 @@ export const WRUN_OPTIONS_CHAIN_UNAVAILABLE_CODE = 'wrun_options_chain_unavailab
|
|
|
262
271
|
export const WRUN_OPTIONS_CHAIN_VENUE_UNAVAILABLE_CODE = 'wrun_options_chain_venue_unavailable';
|
|
263
272
|
export const WRUN_OPTIONS_CHAIN_ONE_VENUE_CODE = 'wrun_options_chain_one_venue';
|
|
264
273
|
export const WRUN_OPTIONS_CHAIN_EXPIRIES_CODE = 'wrun_options_chain_expiries';
|
|
274
|
+
/**
|
|
275
|
+
* The ONE refusal of a venue the crypto-options gate keeps dark (a guest: reason `flag-off`), for every chain class:
|
|
276
|
+
* the options chain decision's venue word and a scope across venues (`options_flow`, whose `venue` knob names the
|
|
277
|
+
* venue's exchange). `who` names the input and its class, `venue` the word it declared, `name` the venue's name
|
|
278
|
+
* (`wrunOptionsChainGatedVenueName`), `coin` the coin asked about and `wayOut` what the input may declare instead.
|
|
279
|
+
*/
|
|
280
|
+
export function wrunOptionsChainFlagOffRefusal(args) {
|
|
281
|
+
return {
|
|
282
|
+
ok: false,
|
|
283
|
+
code: WRUN_OPTIONS_CHAIN_VENUE_UNAVAILABLE_CODE,
|
|
284
|
+
message: `${args.who} with venue "${args.venue}", but ${args.name} chains are not enabled on this chart (${WRUN_OPTIONS_CHAIN_VENUE_UNAVAILABLE_CODE}: the crypto-options flag is off): ${args.wayOut}`,
|
|
285
|
+
reason: 'flag-off',
|
|
286
|
+
venueName: args.name,
|
|
287
|
+
...(args.coin !== '' ? { coin: args.coin } : {}),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
265
290
|
/** The name each plane's chain directory goes by in a refusal's technical words. */
|
|
266
291
|
const WRUN_OPTIONS_CHAIN_DIRECTORY_NAMES = Object.freeze({
|
|
267
292
|
cme: 'CME',
|
|
@@ -325,7 +350,13 @@ export function decideWrunOptionsChainIdentity(args) {
|
|
|
325
350
|
const name = WRUN_OPTIONS_CHAIN_CRYPTO_VENUE_NAMES[venue];
|
|
326
351
|
const coin = cryptoVenues.coin.length > 0 ? cryptoVenues.coin : deribitCoin;
|
|
327
352
|
if (!cryptoVenues.enabled) {
|
|
328
|
-
return
|
|
353
|
+
return wrunOptionsChainFlagOffRefusal({
|
|
354
|
+
who,
|
|
355
|
+
venue,
|
|
356
|
+
name,
|
|
357
|
+
coin,
|
|
358
|
+
wayOut: `declare venue "auto" (the chart's own market when it is an options venue, else the coin's Deribit chain) or "deribit"`,
|
|
359
|
+
});
|
|
329
360
|
}
|
|
330
361
|
const source = cryptoVenues.sourceOf(venue);
|
|
331
362
|
if (source !== undefined)
|
|
@@ -451,8 +482,11 @@ function finiteOr(value, fallback) {
|
|
|
451
482
|
}
|
|
452
483
|
/** A lane row `[ts, [tuple], ...]` (the K_OPTIONS_CHAIN worker's shape,
|
|
453
484
|
* nested like the volume-profile lane's) read back as tuples; a malformed
|
|
454
|
-
* tuple (not an array of
|
|
455
|
-
* lane's malformed-bucket rule.
|
|
485
|
+
* tuple (not an array of ten finite numbers) is skipped whole, the VP
|
|
486
|
+
* lane's malformed-bucket rule. The run itself reads the rows through the
|
|
487
|
+
* shared host's kit adapter (`adaptWrunCells`), which takes nested tuples
|
|
488
|
+
* only: the worker sends the row nested (OPTLOAD G5 keeps it so until that
|
|
489
|
+
* adapter reads packed blocks). */
|
|
456
490
|
export function wrunOptionsChainRowTuples(row) {
|
|
457
491
|
const tuples = [];
|
|
458
492
|
for (let at = 1; at < row.length; at += 1) {
|
|
@@ -86,7 +86,7 @@ import type { WrunLiveApplied } from './wrun-live-patch.util.js';
|
|
|
86
86
|
import type { WrunCandleEvidence, WrunCandleFingerprint } from './wrun-prefix-proof.util.js';
|
|
87
87
|
import type { WrunInputCarry, WrunPinnedLeg } from './wrun-source-rows.util.js';
|
|
88
88
|
import type { WrunRetainedRange } from './wrun-run-retained.util.js';
|
|
89
|
-
import type { WrunRerunOptions, WrunRunSettledEvent, WrunRunWindow } from './wrun-lifecycle.contract.js';
|
|
89
|
+
import type { WrunRerunOptions, WrunRunReason, WrunRunSettledEvent, WrunRunWindow } from './wrun-lifecycle.contract.js';
|
|
90
90
|
export interface WrunOverlayDriver {
|
|
91
91
|
chartIndex: number;
|
|
92
92
|
/** True while the overlay's TECHNICAL_SCRIPT record is still on the chart. */
|
|
@@ -111,11 +111,24 @@ export interface WrunRunSettleNote {
|
|
|
111
111
|
outcome: WrunSettingsRunOutcome;
|
|
112
112
|
reason?: string;
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* The attempt that started a source ladder's episode (wrun-overlay-recovery.util `armWrunSourceRecovery`), as it stood
|
|
116
|
+
* then: who asked and why. A rung answers an attempt of the same origin and reason (`beginWrunRunAttempt`), so the
|
|
117
|
+
* record the ladder ends on, and its `wrun_failure_shown` run kind, name that episode (a restore, a person's add, a
|
|
118
|
+
* live rebuild), never the rung.
|
|
119
|
+
*/
|
|
120
|
+
export interface WrunRunEpisode {
|
|
121
|
+
origin: 'user' | 'system';
|
|
122
|
+
reason: WrunRunReason | 'mount';
|
|
123
|
+
}
|
|
114
124
|
/** Register (or clear, with null) the chart main-rows identity reader the
|
|
115
125
|
* pan wave's coverage skip compares runs by. */
|
|
116
126
|
export declare function setWrunChartRowsIdentityReader(reader: ((chartIndex: number, indicatorId?: string) => string | undefined) | null): void;
|
|
117
127
|
/** Subscribe to every settled executor run (wave, initial compute, follow-up):
|
|
118
|
-
* once per run, with the run's reason and outcome. Returns the unsubscribe.
|
|
128
|
+
* once per run, with the run's reason and outcome. Returns the unsubscribe.
|
|
129
|
+
* Only a run of an overlay that still stands is announced: a run that settles
|
|
130
|
+
* after its overlay's teardown is not (the id may already name a same-id
|
|
131
|
+
* remount, which would read it as its own); the ring still records it. */
|
|
119
132
|
export declare function onWrunOverlayRunSettled(fn: (event: WrunRunSettledEvent) => void): () => void;
|
|
120
133
|
/** Subscribe to the run pass's success marker (`markWrunOverlayComputeSucceeded`),
|
|
121
134
|
* with the driver's chart index. Returns the unsubscribe. */
|
|
@@ -617,9 +630,11 @@ export interface WrunPrefixRunWindow extends WrunRunWindow {
|
|
|
617
630
|
/** The hidden head's first candle; `fromMs`/`toMs` stay the landed range. */
|
|
618
631
|
warmupFromTs?: number;
|
|
619
632
|
}
|
|
620
|
-
/** The rerun options a pan wave hands the executor: the contract's plus its prefix tag
|
|
633
|
+
/** The rerun options a pan wave hands the executor: the contract's plus its prefix tag; a source-recovery rung's
|
|
634
|
+
* plus its episode (`WrunRunEpisode`). */
|
|
621
635
|
export type WrunWaveRerunOptions = WrunRerunOptions & {
|
|
622
636
|
prefix?: WrunPrefixRequest;
|
|
637
|
+
episode?: WrunRunEpisode;
|
|
623
638
|
};
|
|
624
639
|
/** The prefix side the run pass registers at its import (none of it throws). `plan`: the door's plan
|
|
625
640
|
* (the owner stamped pending), undefined to run the wave whole. `start`: a tagged wave as it starts,
|
|
@@ -78,7 +78,7 @@ import { startVisibleTimeout } from '../common/visible-timeout.util.js';
|
|
|
78
78
|
import { wrunHostVisibleClock } from './wrun-host-visible-clock.util.js';
|
|
79
79
|
import { WRUN_RUN_DEADLINE_MS } from './wrun-deadline.util.js';
|
|
80
80
|
import { WrunChartGoneError, WrunDeadlineError } from './wrun-registry-errors.util.js';
|
|
81
|
-
import { closeWrunRefusalAttempts, liveWrunRefusalAttempt, openWrunRefusalAttempt, wrunRefusalAttemptOrigin, } from './wrun-refusal-surface.util.js';
|
|
81
|
+
import { closeWrunRefusalAttempts, concludeWrunRefusalAttempt, liveWrunRefusalAttempt, openWrunRefusalAttempt, wrunRefusalAttemptOrigin, } from './wrun-refusal-surface.util.js';
|
|
82
82
|
import { attachWrunRefusal, stampWrunRefusalTelemetry } from './wrun-refusal.util.js';
|
|
83
83
|
import { wrunRunFailedIdentityOf } from './wrun-cap-notice.util.js';
|
|
84
84
|
import { wrunChartHostEnv } from '../../host-env.js';
|
|
@@ -118,6 +118,8 @@ function wrunRunRequestOf(options) {
|
|
|
118
118
|
...(userOrigin ? { userOrigin } : {}),
|
|
119
119
|
// Only a pan wave is ever planned as a prefix run.
|
|
120
120
|
...(options?.prefix && reason === 'lazy-range-refresh' ? { prefix: options.prefix } : {}),
|
|
121
|
+
// Only a source-recovery rung answers its episode's attempt.
|
|
122
|
+
...(options?.episode && reason === 'source-recovery' ? { episode: options.episode } : {}),
|
|
121
123
|
};
|
|
122
124
|
}
|
|
123
125
|
/** The options a driver's rerun receives: the reason and the window only. */
|
|
@@ -137,12 +139,15 @@ function mergeWrunRunRequests(pending, incoming) {
|
|
|
137
139
|
// A prefix tag survives only a merge of two planned pan waves (the newer tag: it is replanned
|
|
138
140
|
// when the run starts anyway); any full request merged with one wins (C1 v3).
|
|
139
141
|
const prefix = pending.prefix !== undefined && incoming.prefix !== undefined ? { prefix: incoming.prefix } : {};
|
|
142
|
+
// A rung's episode survives only while the merged request is still a rung (the newer rung's).
|
|
143
|
+
const rungEpisode = reason === 'source-recovery' ? (incoming.episode ?? pending.episode) : undefined;
|
|
144
|
+
const episode = rungEpisode !== undefined ? { episode: rungEpisode } : {};
|
|
140
145
|
if (!pending.window || !incoming.window)
|
|
141
|
-
return { reason, ...origin, ...prefix };
|
|
146
|
+
return { reason, ...origin, ...prefix, ...episode };
|
|
142
147
|
const window = incoming.window.toMs - incoming.window.fromMs >= pending.window.toMs - pending.window.fromMs
|
|
143
148
|
? incoming.window
|
|
144
149
|
: pending.window;
|
|
145
|
-
return { reason, window, ...origin, ...prefix };
|
|
150
|
+
return { reason, window, ...origin, ...prefix, ...episode };
|
|
146
151
|
}
|
|
147
152
|
/** Merge a request into the queued follow-up; a prefix tag the merge dropped will never run. */
|
|
148
153
|
function queueWrunRunRequest(indicatorId, state, incoming) {
|
|
@@ -165,7 +170,12 @@ function queueWrunRunRequest(indicatorId, state, incoming) {
|
|
|
165
170
|
* a restore, which is system and never noticed);
|
|
166
171
|
* - every other request is the chart's own: it keeps a user attempt still
|
|
167
172
|
* waiting on its first answer (the loader's add while a pan wave computes
|
|
168
|
-
* first)
|
|
173
|
+
* first);
|
|
174
|
+
* - a source-recovery rung opens an attempt of its episode's origin and
|
|
175
|
+
* reason (`WrunRunEpisode`), so the record the ladder ends on names the
|
|
176
|
+
* episode that started it, concluded at once: automatic recovery never
|
|
177
|
+
* toasts;
|
|
178
|
+
* - else it opens a system attempt.
|
|
169
179
|
* `owned`: the attempt is this run's to answer, so its settlement concludes it.
|
|
170
180
|
*/
|
|
171
181
|
function beginWrunRunAttempt(indicatorId, state, request) {
|
|
@@ -182,6 +192,11 @@ function beginWrunRunAttempt(indicatorId, state, request) {
|
|
|
182
192
|
if (live && live.origin === 'user' && live.generation !== state.answeredUserAttempt) {
|
|
183
193
|
return { token: live, owned: false };
|
|
184
194
|
}
|
|
195
|
+
if (request.episode !== undefined) {
|
|
196
|
+
const token = openWrunRefusalAttempt(chartIndex, indicatorId, request.episode);
|
|
197
|
+
concludeWrunRefusalAttempt(token);
|
|
198
|
+
return { token, owned: true };
|
|
199
|
+
}
|
|
185
200
|
return {
|
|
186
201
|
token: openWrunRefusalAttempt(chartIndex, indicatorId, { origin: 'system', reason: request.reason }),
|
|
187
202
|
owned: true,
|
|
@@ -258,7 +273,10 @@ function notifyWrunOverlayHooks(hooks, label, indicatorId, ...args) {
|
|
|
258
273
|
}
|
|
259
274
|
}
|
|
260
275
|
/** Subscribe to every settled executor run (wave, initial compute, follow-up):
|
|
261
|
-
* once per run, with the run's reason and outcome. Returns the unsubscribe.
|
|
276
|
+
* once per run, with the run's reason and outcome. Returns the unsubscribe.
|
|
277
|
+
* Only a run of an overlay that still stands is announced: a run that settles
|
|
278
|
+
* after its overlay's teardown is not (the id may already name a same-id
|
|
279
|
+
* remount, which would read it as its own); the ring still records it. */
|
|
262
280
|
export function onWrunOverlayRunSettled(fn) {
|
|
263
281
|
runSettledHooks.add(fn);
|
|
264
282
|
return () => {
|
|
@@ -926,8 +944,9 @@ function isSameWrunFailure(previous, next) {
|
|
|
926
944
|
* and the add/rehydrate initial-compute entry. The run consumes the taps
|
|
927
945
|
* latched at its start: they settle with THIS run's own outcome (a dropped
|
|
928
946
|
* run hands them to the run that replaces it, C4). Every
|
|
929
|
-
* settled run is announced once to the run-settled
|
|
930
|
-
* once to the store's settings sync
|
|
947
|
+
* settled run of a standing overlay is announced once to the run-settled
|
|
948
|
+
* subscribers, and reported once to the store's settings sync (a torn-down
|
|
949
|
+
* overlay's run: to the ring only). */
|
|
931
950
|
function beginExecutorRun(indicatorId, state, planned) {
|
|
932
951
|
// A planned pan wave is replanned against the current session as it starts (C1 v3): its prefix
|
|
933
952
|
// window, the full wave it falls back to, or nothing left to compute (dropped: no run at all).
|
|
@@ -948,6 +967,12 @@ function beginExecutorRun(indicatorId, state, planned) {
|
|
|
948
967
|
// The run settled dropped: the follow-up decision says whether any run answers for it.
|
|
949
968
|
let dropped = false;
|
|
950
969
|
const announce = (ok, error) => {
|
|
970
|
+
// A run settles into its own overlay only. Once that overlay was torn down (a removal, a same-id restore, a chart
|
|
971
|
+
// teardown: `releaseWrunOverlayLiveSession`), the id may already name a successor (a remount of the same row),
|
|
972
|
+
// whose subscribers would read this run, typically dropped by the teardown's cancel of its row-source ask, as
|
|
973
|
+
// their own first run. Its settle is the ring's alone then (`reportWrunRunSettled`, store left out).
|
|
974
|
+
if (drivers.get(indicatorId) !== state)
|
|
975
|
+
return;
|
|
951
976
|
const failedIdentity = ok ? undefined : wrunRunFailedIdentityOf(error);
|
|
952
977
|
const event = {
|
|
953
978
|
indicatorId,
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* - the failure class each settled run leaves for that heal
|
|
13
13
|
* (`classifyWrunRunFailure`);
|
|
14
14
|
* - the secondary-source ladder (`armWrunSourceRecovery`): kScript's rungs and
|
|
15
|
-
* attempt cap (kscript-source-degrade.leaf), one whole run per rung
|
|
15
|
+
* attempt cap (kscript-source-degrade.leaf), one whole run per rung, joining
|
|
16
|
+
* or adopting the read a degraded lane left out (run-schedule/wrun-late-reads.util);
|
|
16
17
|
* - the gate session (`rerunWrunGatePlaneReaders`): a run of every overlay
|
|
17
18
|
* that read a gate plane on each edge of that plane's session latch
|
|
18
19
|
* (another screen took the session, this tab took it back);
|
|
@@ -82,11 +83,16 @@ export declare function healWrunOverlayIfIdle(chartIndex: number, indicatorId: s
|
|
|
82
83
|
* executor's single flight); a hold re-arms the same step; a run that lands
|
|
83
84
|
* every lane retires the episode ('recovered', from the run); after the last
|
|
84
85
|
* rung the sources turn terminal in the degrade registry, so the chip stops
|
|
85
|
-
* promising a retry and its Retry is the way back in.
|
|
86
|
+
* promising a retry and its Retry is the way back in. While a degraded lane's
|
|
87
|
+
* read is still out (run-schedule/wrun-late-reads.util) the ladder never asks
|
|
88
|
+
* it again: the rung runs the moment the reads answer (their rows adopted),
|
|
89
|
+
* and a rung that comes due first waits for them (their read joined).
|
|
86
90
|
*/
|
|
87
91
|
export declare function armWrunSourceRecovery(chartIndex: number, indicatorId: string, degraded: ReadonlyArray<WrunDegradedLane>): void;
|
|
88
92
|
/** Drop one overlay's source ladder: every lane landed ('recovered'), a user
|
|
89
|
-
* rebuild took over ('rebuild'), or the overlay left ('teardown').
|
|
93
|
+
* rebuild took over ('rebuild'), or the overlay left ('teardown'). A ladder
|
|
94
|
+
* that recovered or left takes the reads its lanes left out with it: nothing
|
|
95
|
+
* will adopt them. */
|
|
90
96
|
export declare function retireWrunSourceRecovery(indicatorId: string, cause: 'recovered' | 'rebuild' | 'teardown'): void;
|
|
91
97
|
/**
|
|
92
98
|
* The latch's edge (gate-session-latch.util, published by the plane's owner): every overlay whose latest full run read
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getWrunOverlayLiveContext, hasWrunOverlayDriver, isWrunOverlayRerunInFlight, onWrunOverlayLiveTeardown, onWrunOverlayRunSettled, rerunWrunOverlayForChartWave, suspendWrunOverlayLiveSession, } from './wrun-overlay-drivers.util.js';
|
|
2
|
+
import { liveWrunRefusalAttempt, wrunRefusalAttemptFacts } from './wrun-refusal-surface.util.js';
|
|
2
3
|
import { isWrunOverlayPausedError, isWrunQuarantinedError, isWrunVenueBlockedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunWorkerPoisonError, } from './wrun-registry-errors.util.js';
|
|
3
4
|
import { attachWrunRefusal } from './wrun-refusal.util.js';
|
|
4
5
|
import { onGateSessionLatchChange } from '../v2/gate-session-latch.util.js';
|
|
@@ -6,6 +7,7 @@ import { __resetWrunGatePlaneReadersForTests, forgetWrunGatePlaneReader, wrunGat
|
|
|
6
7
|
import { overlayExecutionGuardKey } from '../chart/overlay-execution-guard-key.leaf.js';
|
|
7
8
|
import { LOCAL_ENGINE_SELF_HEAL_BASE_DELAY_MS, openLocalEngineSelfHealGate, recordLocalEngineSelfHealAttempt, } from '../chart/local-engine-self-heal-backoff.util.js';
|
|
8
9
|
import { KSCRIPT_SECONDARY_SOURCE_MAX_RECOVERY_ATTEMPTS, KSCRIPT_SECONDARY_SOURCE_RETRY_DELAYS_MS, } from '../chart/kscript-source-degrade.leaf.js';
|
|
10
|
+
import { __resetWrunLateReadsForTests, forgetWrunLateReads, onWrunLateReadSettled, wrunLateReadsAnswered, wrunLateReadsOut, } from './run-schedule/wrun-late-reads.util.js';
|
|
9
11
|
import { isKScriptDisplayBlockedOnExchange, } from '../chart/kscript-venue-policy.util.js';
|
|
10
12
|
import { wrunRunFailedIdentityOf, wrunRunIdentityOf } from './wrun-cap-notice.util.js';
|
|
11
13
|
import { wrunChartHostEnv } from '../../host-env.js';
|
|
@@ -494,6 +496,11 @@ async function runWrunTransientRerunTail(chartIndex, indicatorId, trigger, token
|
|
|
494
496
|
report('rerun');
|
|
495
497
|
void work.catch(() => undefined);
|
|
496
498
|
}
|
|
499
|
+
/** The attempt of the run arming an episode now (the overlay's live attempt), or undefined when none is open. */
|
|
500
|
+
function wrunSourceRecoveryEpisodeOf(chartIndex, indicatorId) {
|
|
501
|
+
const facts = wrunRefusalAttemptFacts(liveWrunRefusalAttempt(chartIndex, indicatorId));
|
|
502
|
+
return facts?.reason === undefined ? undefined : { origin: facts.origin, reason: facts.reason };
|
|
503
|
+
}
|
|
497
504
|
const sourceRecoveries = new Map();
|
|
498
505
|
// Settled executor runs per overlay. Runs are single flight per overlay, so an
|
|
499
506
|
// arming whose count equals the current one happened inside the run settling now.
|
|
@@ -505,7 +512,10 @@ const settledRuns = new Map();
|
|
|
505
512
|
* executor's single flight); a hold re-arms the same step; a run that lands
|
|
506
513
|
* every lane retires the episode ('recovered', from the run); after the last
|
|
507
514
|
* rung the sources turn terminal in the degrade registry, so the chip stops
|
|
508
|
-
* promising a retry and its Retry is the way back in.
|
|
515
|
+
* promising a retry and its Retry is the way back in. While a degraded lane's
|
|
516
|
+
* read is still out (run-schedule/wrun-late-reads.util) the ladder never asks
|
|
517
|
+
* it again: the rung runs the moment the reads answer (their rows adopted),
|
|
518
|
+
* and a rung that comes due first waits for them (their read joined).
|
|
509
519
|
*/
|
|
510
520
|
export function armWrunSourceRecovery(chartIndex, indicatorId, degraded) {
|
|
511
521
|
if (!hasWrunOverlayDriver(indicatorId))
|
|
@@ -525,6 +535,9 @@ export function armWrunSourceRecovery(chartIndex, indicatorId, degraded) {
|
|
|
525
535
|
terminal: false,
|
|
526
536
|
armedAtSettle: 0,
|
|
527
537
|
lastArmed: [],
|
|
538
|
+
waitingOnReads: false,
|
|
539
|
+
unwatch: undefined,
|
|
540
|
+
episode: wrunSourceRecoveryEpisodeOf(chartIndex, indicatorId),
|
|
528
541
|
};
|
|
529
542
|
sourceRecoveries.set(indicatorId, recovery);
|
|
530
543
|
}
|
|
@@ -538,40 +551,130 @@ export function armWrunSourceRecovery(chartIndex, indicatorId, degraded) {
|
|
|
538
551
|
markWrunSourcesTerminal(indicatorId, recovery);
|
|
539
552
|
return;
|
|
540
553
|
}
|
|
541
|
-
|
|
554
|
+
watchWrunSourceRecoveryReads(indicatorId, recovery);
|
|
555
|
+
if (recovery.timer !== undefined || recovery.running || recovery.waitingOnReads)
|
|
542
556
|
return;
|
|
543
557
|
scheduleWrunSourceRung(indicatorId, recovery);
|
|
544
558
|
}
|
|
545
559
|
/** Drop one overlay's source ladder: every lane landed ('recovered'), a user
|
|
546
|
-
* rebuild took over ('rebuild'), or the overlay left ('teardown').
|
|
560
|
+
* rebuild took over ('rebuild'), or the overlay left ('teardown'). A ladder
|
|
561
|
+
* that recovered or left takes the reads its lanes left out with it: nothing
|
|
562
|
+
* will adopt them. */
|
|
547
563
|
export function retireWrunSourceRecovery(indicatorId, cause) {
|
|
548
564
|
const recovery = sourceRecoveries.get(indicatorId);
|
|
565
|
+
if (cause !== 'rebuild')
|
|
566
|
+
forgetWrunLateReads(indicatorId);
|
|
549
567
|
if (!recovery)
|
|
550
568
|
return;
|
|
551
569
|
if (recovery.timer !== undefined)
|
|
552
570
|
clearTimeout(recovery.timer);
|
|
553
571
|
recovery.timer = undefined;
|
|
572
|
+
unwatchWrunSourceRecoveryReads(recovery);
|
|
554
573
|
sourceRecoveries.delete(indicatorId);
|
|
555
574
|
ring('wrun-source-recovery-retired', { chartIndex: recovery.chartIndex, indicatorId, cause, step: recovery.step });
|
|
556
575
|
}
|
|
576
|
+
function unwatchWrunSourceRecoveryReads(recovery) {
|
|
577
|
+
recovery.unwatch?.();
|
|
578
|
+
recovery.unwatch = undefined;
|
|
579
|
+
recovery.waitingOnReads = false;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* The reads the episode's lanes left out (run-schedule/wrun-late-reads.util), watched while one is out or answered:
|
|
583
|
+
* once none of its lanes' reads is out any more, a read that answered with rows runs the rung now (the run adopts the
|
|
584
|
+
* rows, no ask), and a rung that came due while one was out (`waitingOnReads`) runs whatever they answered (a failed
|
|
585
|
+
* read is no read: that rung asks the wire). A read that answered before the arm runs the rung on the next turn. Every
|
|
586
|
+
* read failed and no rung due: the watch ends and the rung's own timer stands.
|
|
587
|
+
*/
|
|
588
|
+
function watchWrunSourceRecoveryReads(indicatorId, recovery) {
|
|
589
|
+
if (recovery.unwatch !== undefined)
|
|
590
|
+
return;
|
|
591
|
+
const lanes = () => [...recovery.lanes.keys()];
|
|
592
|
+
const out = wrunLateReadsOut(indicatorId, lanes());
|
|
593
|
+
const answered = wrunLateReadsAnswered(indicatorId, lanes());
|
|
594
|
+
if (out.length === 0 && answered.length === 0)
|
|
595
|
+
return;
|
|
596
|
+
const onSettled = () => {
|
|
597
|
+
if (sourceRecoveries.get(indicatorId) !== recovery || recovery.running || recovery.terminal)
|
|
598
|
+
return;
|
|
599
|
+
const stillOut = wrunLateReadsOut(indicatorId, lanes());
|
|
600
|
+
if (stillOut.length > 0)
|
|
601
|
+
return;
|
|
602
|
+
const landed = wrunLateReadsAnswered(indicatorId, lanes());
|
|
603
|
+
const due = recovery.waitingOnReads;
|
|
604
|
+
unwatchWrunSourceRecoveryReads(recovery);
|
|
605
|
+
if (landed.length === 0 && !due)
|
|
606
|
+
return;
|
|
607
|
+
if (recovery.timer !== undefined)
|
|
608
|
+
clearTimeout(recovery.timer);
|
|
609
|
+
recovery.timer = undefined;
|
|
610
|
+
ring('wrun-source-recovery-reads-settled', {
|
|
611
|
+
chartIndex: recovery.chartIndex,
|
|
612
|
+
indicatorId,
|
|
613
|
+
step: recovery.step,
|
|
614
|
+
landed,
|
|
615
|
+
due,
|
|
616
|
+
});
|
|
617
|
+
// Past the last rung the ladder decides now that no read is out (scheduleWrunSourceRung): rows run one more rung
|
|
618
|
+
// that adopts them, nothing gives up.
|
|
619
|
+
if (recovery.step >= SOURCE_RECOVERY_RUNGS) {
|
|
620
|
+
scheduleWrunSourceRung(indicatorId, recovery);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
void runWrunSourceRung(indicatorId, recovery).catch((error) => {
|
|
624
|
+
console.warn(`[wrun] source recovery rung failed for '${indicatorId}':`, error);
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
recovery.unwatch = onWrunLateReadSettled(indicatorId, onSettled);
|
|
628
|
+
if (out.length === 0)
|
|
629
|
+
queueMicrotask(onSettled);
|
|
630
|
+
}
|
|
557
631
|
function markWrunSourcesTerminal(indicatorId, recovery) {
|
|
558
632
|
recovery.terminal = true;
|
|
559
633
|
wrunChartHostEnv().chart.markSourcesTerminal(overlayExecutionGuardKey(recovery.chartIndex, indicatorId), [
|
|
560
634
|
...recovery.lanes.keys(),
|
|
561
635
|
]);
|
|
562
636
|
}
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
637
|
+
/**
|
|
638
|
+
* The ladder's next step: a rung on its delay while rungs are left (a held rung asks again on the same delay). Past the
|
|
639
|
+
* last one the ladder never turns terminal while a degraded lane's read is still out (the last rung's own, which its
|
|
640
|
+
* budget abandoned, may yet answer): it waits for the read (`watchWrunSourceRecoveryReads`); a read that answered with
|
|
641
|
+
* rows then runs one more rung at once, which adopts them (kScript's late-arrival recovery, inside the episode's
|
|
642
|
+
* attempt cap); only a read that failed, or none at all, turns the sources terminal.
|
|
643
|
+
*/
|
|
644
|
+
function scheduleWrunSourceRung(indicatorId, recovery, held = false) {
|
|
645
|
+
let adopt = false;
|
|
646
|
+
if (recovery.step >= SOURCE_RECOVERY_RUNGS && !held) {
|
|
647
|
+
const lanes = [...recovery.lanes.keys()];
|
|
648
|
+
const out = wrunLateReadsOut(indicatorId, lanes);
|
|
649
|
+
if (out.length > 0) {
|
|
650
|
+
recovery.waitingOnReads = true;
|
|
651
|
+
watchWrunSourceRecoveryReads(indicatorId, recovery);
|
|
652
|
+
ring('wrun-source-recovery-terminal-waits', {
|
|
653
|
+
chartIndex: recovery.chartIndex,
|
|
654
|
+
indicatorId,
|
|
655
|
+
step: recovery.step,
|
|
656
|
+
lanes: out,
|
|
657
|
+
});
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
adopt =
|
|
661
|
+
recovery.step < KSCRIPT_SECONDARY_SOURCE_MAX_RECOVERY_ATTEMPTS &&
|
|
662
|
+
wrunLateReadsAnswered(indicatorId, lanes).length > 0;
|
|
663
|
+
if (!adopt) {
|
|
664
|
+
markWrunSourcesTerminal(indicatorId, recovery);
|
|
665
|
+
ring('wrun-source-recovery-terminal', {
|
|
666
|
+
chartIndex: recovery.chartIndex,
|
|
667
|
+
indicatorId,
|
|
668
|
+
lanes,
|
|
669
|
+
attempts: recovery.step,
|
|
670
|
+
});
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
573
673
|
}
|
|
574
|
-
|
|
674
|
+
// A rung adopting a read's rows runs on the next turn; a held rung past the last waits the last delay.
|
|
675
|
+
const delayMs = adopt
|
|
676
|
+
? 0
|
|
677
|
+
: KSCRIPT_SECONDARY_SOURCE_RETRY_DELAYS_MS[Math.min(recovery.step, SOURCE_RECOVERY_RUNGS - 1)];
|
|
575
678
|
recovery.timer = setTimeout(() => {
|
|
576
679
|
recovery.timer = undefined;
|
|
577
680
|
void runWrunSourceRung(indicatorId, recovery).catch((error) => {
|
|
@@ -583,12 +686,26 @@ async function runWrunSourceRung(indicatorId, recovery) {
|
|
|
583
686
|
const current = () => sourceRecoveries.get(indicatorId) === recovery && recovery.timer === undefined;
|
|
584
687
|
if (!current())
|
|
585
688
|
return;
|
|
689
|
+
// A degraded lane's read is still out: the rung joins it instead of asking the same window again. It runs once the
|
|
690
|
+
// reads settled (watchWrunSourceRecoveryReads), its run adopting what they answered.
|
|
691
|
+
const out = wrunLateReadsOut(indicatorId, recovery.lanes.keys());
|
|
692
|
+
if (out.length > 0) {
|
|
693
|
+
recovery.waitingOnReads = true;
|
|
694
|
+
watchWrunSourceRecoveryReads(indicatorId, recovery);
|
|
695
|
+
ring('wrun-source-recovery-joined', {
|
|
696
|
+
chartIndex: recovery.chartIndex,
|
|
697
|
+
indicatorId,
|
|
698
|
+
step: recovery.step,
|
|
699
|
+
lanes: out,
|
|
700
|
+
});
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
586
703
|
const hold = await wrunOverlayHold(recovery.chartIndex, indicatorId, 'source-recovery');
|
|
587
704
|
if (!current())
|
|
588
705
|
return;
|
|
589
706
|
if (hold !== null) {
|
|
590
707
|
ring('wrun-source-recovery-held', { chartIndex: recovery.chartIndex, indicatorId, hold, step: recovery.step });
|
|
591
|
-
scheduleWrunSourceRung(indicatorId, recovery);
|
|
708
|
+
scheduleWrunSourceRung(indicatorId, recovery, true);
|
|
592
709
|
return;
|
|
593
710
|
}
|
|
594
711
|
recovery.step += 1;
|
|
@@ -598,7 +715,12 @@ async function runWrunSourceRung(indicatorId, recovery) {
|
|
|
598
715
|
attempt: recovery.step,
|
|
599
716
|
lanes: [...recovery.lanes.keys()],
|
|
600
717
|
});
|
|
601
|
-
|
|
718
|
+
// The rung answers an attempt of its episode's origin and reason (`episode`), so the record it ends on names the
|
|
719
|
+
// episode that started the ladder.
|
|
720
|
+
const work = rerunWrunOverlayForChartWave(indicatorId, {
|
|
721
|
+
reason: 'source-recovery',
|
|
722
|
+
...(recovery.episode !== undefined ? { episode: recovery.episode } : {}),
|
|
723
|
+
});
|
|
602
724
|
if (work) {
|
|
603
725
|
recovery.running = true;
|
|
604
726
|
try {
|
|
@@ -611,10 +733,14 @@ async function runWrunSourceRung(indicatorId, recovery) {
|
|
|
611
733
|
recovery.running = false;
|
|
612
734
|
}
|
|
613
735
|
}
|
|
614
|
-
// The rung's run re-armed (the timer is set), retired (recovered) or left
|
|
736
|
+
// The rung's run re-armed (the timer is set, or the ladder waits on a read it left out), retired (recovered) or left
|
|
615
737
|
// the lanes as they were (failed before the lanes): the next step decides.
|
|
616
|
-
if (sourceRecoveries.get(indicatorId) !== recovery ||
|
|
738
|
+
if (sourceRecoveries.get(indicatorId) !== recovery ||
|
|
739
|
+
recovery.timer !== undefined ||
|
|
740
|
+
recovery.waitingOnReads ||
|
|
741
|
+
recovery.terminal) {
|
|
617
742
|
return;
|
|
743
|
+
}
|
|
618
744
|
scheduleWrunSourceRung(indicatorId, recovery);
|
|
619
745
|
}
|
|
620
746
|
// ---------------------------------------------------------------------------
|
|
@@ -955,8 +1081,10 @@ export function __resetWrunOverlayRecoveryForTests() {
|
|
|
955
1081
|
for (const recovery of sourceRecoveries.values()) {
|
|
956
1082
|
if (recovery.timer !== undefined)
|
|
957
1083
|
clearTimeout(recovery.timer);
|
|
1084
|
+
unwatchWrunSourceRecoveryReads(recovery);
|
|
958
1085
|
}
|
|
959
1086
|
sourceRecoveries.clear();
|
|
1087
|
+
__resetWrunLateReadsForTests();
|
|
960
1088
|
settledRuns.clear();
|
|
961
1089
|
casualtyDeaths.clear();
|
|
962
1090
|
casualtyCharts.clear();
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
import type { WrunDegradedLane, WrunRunReason, WrunRunWindow } from './wrun-lifecycle.contract.js';
|
|
65
65
|
import { type WrunIntegrationRoute } from './wrun-integration-route.util.js';
|
|
66
66
|
import type { OverlayRunInterval } from '../chart/indicator-run-interval.util.js';
|
|
67
|
-
import { type
|
|
67
|
+
import { type WrunPrefixFeedClause } from './run-schedule/wrun-prefix-feeds.util.js';
|
|
68
68
|
import { type WrunCandleGroup, type WrunFillPair, type WrunRunResult } from '../chart/wrun-run-result.util.js';
|
|
69
69
|
import { type WrunEarningsMarket } from './wrun-earnings-facts.util.js';
|
|
70
70
|
import { type WrunRunHealth } from './wrun-run-health.util.js';
|
|
@@ -203,6 +203,13 @@ export interface WrunRunComputedFor {
|
|
|
203
203
|
* type. Synchronous over what it reads, so the caller judges in the same task as the act the verdict guards.
|
|
204
204
|
*/
|
|
205
205
|
export declare function wrunRunSupersededReason(run: WrunRunComputedFor): WrunRunSupersededReason | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* Where a run stands when it fails (the `stage` of `wrun-run-failed`): its head (the holds, the walls, the market
|
|
208
|
+
* reads), its lanes (the plans and the fetches of the browser lanes), the compute (the sandbox worker, or the row
|
|
209
|
+
* source's own: the cloud), the integrate (the adapter, the frames, the live session's install), a prefix page, or
|
|
210
|
+
* applied (its result reached the chart; bookkeeping after it failed).
|
|
211
|
+
*/
|
|
212
|
+
export type WrunRunStage = 'head' | 'lanes' | 'compute' | 'integrate' | 'prefix' | 'applied';
|
|
206
213
|
/**
|
|
207
214
|
* A failed full run lands on the OVERLAY, not on whoever triggered it: the
|
|
208
215
|
* add mounts first and runs in the background, a rehydrate or chart wave
|
|
@@ -549,6 +556,13 @@ type WrunSourceLaneResults = {
|
|
|
549
556
|
/** The row lanes' rows by instance id; present only when one was dispatched. */
|
|
550
557
|
rowLaneRows?: Record<string, WrunLaneRows>;
|
|
551
558
|
};
|
|
559
|
+
/**
|
|
560
|
+
* The lane runs of one run's groups (`scheduleWrunLaneGroups`: the lanes known at the plan, then each group as its
|
|
561
|
+
* plan resolved) as the one run a single dispatch reports: every result, and every outcome in declaration order (a
|
|
562
|
+
* stable sort, so each group keeps its own order), the degraded ones beside them in the same order. The order names a
|
|
563
|
+
* hold and the records exactly as before the dispatch was split.
|
|
564
|
+
*/
|
|
565
|
+
export declare function mergeWrunSourceLaneRuns(runs: ReadonlyArray<WrunSourceLaneRun>): WrunSourceLaneRun;
|
|
552
566
|
/** One secondary lane's outcome (D2 2.3): its rows, or degraded to empty
|
|
553
567
|
* rows with the cause (a budget expiry, an empty or declined answer, any
|
|
554
568
|
* other rejection). Every cause here is retryable, except an answer the
|
|
@@ -583,11 +597,41 @@ export interface WrunSourceLaneRun {
|
|
|
583
597
|
export interface WrunSourceLanePolicy {
|
|
584
598
|
/** Each lane's budget (kScript's `resolveSecondarySourceBudgetMs`): one for
|
|
585
599
|
* every lane, or each lane's own by its id (the tape's is sized by its
|
|
586
|
-
* history span)
|
|
587
|
-
*
|
|
600
|
+
* history span), counted from the lane's dispatch until a send notice
|
|
601
|
+
* re-anchors it at the send (`WrunLaneSendAnchor`). A lane still out at it
|
|
602
|
+
* degrades (cause 'budget'), its fetch abandoned, not aborted. Absent: the
|
|
603
|
+
* fetch's own deadline only. */
|
|
588
604
|
budgetMs?: number | ((lane: string) => number);
|
|
589
|
-
/**
|
|
590
|
-
|
|
605
|
+
/** The longest a lane waits from its dispatch once a send re-anchored its budget (the shared leaf's
|
|
606
|
+
* `KSCRIPT_SECONDARY_SOURCE_DISPATCH_CAP_MS`, 60 s, when absent): a budget counted from a late send never runs past
|
|
607
|
+
* it. */
|
|
608
|
+
capMs?: number;
|
|
609
|
+
/** Called with each lane id right before its thunk runs, and the lane's send anchor, which the fetch that asks the
|
|
610
|
+
* lane hands its transport. */
|
|
611
|
+
onDispatch?: (lane: string, anchor: WrunLaneSendAnchor) => void;
|
|
612
|
+
/** Called with a lane's own answer when its budget ran out first (never when the answer itself failed): the read is
|
|
613
|
+
* abandoned, never aborted, so it is still out, and a later run's dispatch may join or adopt it
|
|
614
|
+
* (run-schedule/wrun-late-reads.util). */
|
|
615
|
+
onLate?: (lane: string, answer: Promise<WrunLaneRows>) => void;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* A lane's send anchor (`WrunSourceLanePolicy.onDispatch`): the fetch that asks the lane calls `request()` right before
|
|
619
|
+
* it hands a request to the chart's transport, and passes the notice it answers as the transport's send notices
|
|
620
|
+
* (`onDispatched`, and `onSent` where the transport reports the wire send itself). The lane's budget counts from its
|
|
621
|
+
* dispatch until a notice arrives, then from that send (never past the cap from the dispatch), so time a request spends
|
|
622
|
+
* queued on the main thread, behind the socket's open or in the worker's queue never eats the budget of a transport that
|
|
623
|
+
* reports its send, and a transport that never does (a path with no send of its own) degrades at the budget from the
|
|
624
|
+
* dispatch, never later. The request whose notice came first owns the anchor (its later, truer notice moves it again);
|
|
625
|
+
* a request after that answers no notice. A lane that never hands a request to the transport (its own relay
|
|
626
|
+
* fetch, a joined read) keeps its budget from the dispatch. `sentAtMs()` and `nextSend()` let a request's own bound
|
|
627
|
+
* follow the lane's send (`wrunLaneFetchRequest`).
|
|
628
|
+
*/
|
|
629
|
+
export interface WrunLaneSendAnchor {
|
|
630
|
+
request(): (() => void) | undefined;
|
|
631
|
+
/** When the request that owns the anchor was last heard on the wire, or null before any notice. */
|
|
632
|
+
sentAtMs(): number | null;
|
|
633
|
+
/** Settles on the anchor's next notice. */
|
|
634
|
+
nextSend(): Promise<undefined>;
|
|
591
635
|
}
|
|
592
636
|
/**
|
|
593
637
|
* Dispatch every declared lane at once and settle them all (S7, F103/F127:
|
|
@@ -855,4 +899,4 @@ export declare function integrateWrunOutputRows(options: WrunIntegrateOptions):
|
|
|
855
899
|
*/
|
|
856
900
|
export declare function integrateWrunRunThroughRoute(options: WrunIntegrateOptions): WrunIntegrateOutcome;
|
|
857
901
|
/** Why a pan wave runs whole instead of as a prefix run (C1 v3's skip reasons). */
|
|
858
|
-
export type WrunPrefixSkipReason = 'no-context' | 'not-backward-extension' | 'not-audited' | 'version-outside-audit' | `unsupported-outputs:${string}` | 'replay' | 'clamped' | 'htf' | `lanes:${
|
|
902
|
+
export type WrunPrefixSkipReason = 'no-context' | 'not-backward-extension' | 'not-audited' | 'version-outside-audit' | `unsupported-outputs:${string}` | 'replay' | 'clamped' | 'htf' | `lanes:${WrunPrefixFeedClause}` | 'whole-range-script' | 'prefix-unsafe' | 'no-closed-book-observation' | WrunWarmupMiss | 'warmup-cold' | 'candle-revised';
|