@orangecharts/wrun-chart-host 0.4.0 → 0.5.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 +15 -4
- package/dist/constants/exchange-names.leaf.d.ts +8 -0
- package/dist/constants/exchange-names.leaf.js +101 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
- package/dist/constants/opra-compliance.constants.d.ts +19 -0
- package/dist/constants/opra-compliance.constants.js +19 -0
- package/dist/constants/replay-ladder.leaf.d.ts +30 -0
- package/dist/constants/replay-ladder.leaf.js +99 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
- package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
- package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
- package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
- package/dist/constants/scriptEditor/execution.constants.js +14 -0
- package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
- package/dist/constants/wrun-prefix-safe.constants.js +26 -0
- package/dist/host-env.d.ts +313 -18
- package/dist/host-env.js +15 -0
- package/dist/host-ports.types.d.ts +853 -16
- package/dist/index.d.ts +139 -2
- package/dist/index.js +139 -2
- package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
- package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
- package/dist/interfaces/market-event.interface.d.ts +231 -0
- package/dist/interfaces/market-event.interface.js +15 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
- package/dist/interfaces/opra-realtime.interface.js +34 -59
- package/dist/interfaces/replay.interface.d.ts +285 -0
- package/dist/interfaces/replay.interface.js +1 -0
- package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
- package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
- package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
- package/dist/market-data/billing.interface.d.ts +219 -0
- package/dist/market-data/billing.interface.js +58 -0
- package/dist/market-data/venue-governed.util.d.ts +2 -0
- package/dist/market-data/venue-governed.util.js +10 -0
- package/dist/market-data/venue.d.ts +122 -0
- package/dist/market-data/venue.js +1 -0
- package/dist/market-data/venues/index.d.ts +97 -0
- package/dist/market-data/venues/index.js +33 -0
- package/dist/market-data/venues/opra.contract.copy.json +35 -0
- package/dist/market-data/venues/opra.d.ts +70 -0
- package/dist/market-data/venues/opra.js +74 -0
- package/dist/replay/replayIndicatorRows.d.ts +31 -0
- package/dist/replay/replayIndicatorRows.js +117 -0
- package/dist/replay/replayLadder.d.ts +85 -0
- package/dist/replay/replayLadder.js +388 -0
- package/dist/utility/auth/server-clock.util.d.ts +81 -0
- package/dist/utility/auth/server-clock.util.js +238 -0
- package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
- package/dist/utility/chart/builtin-identity.util.js +51 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
- package/dist/utility/chart/cache-alignment.util.js +926 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
- package/dist/utility/chart/chart-mount-epoch.util.d.ts +5 -0
- package/dist/utility/chart/chart-mount-epoch.util.js +29 -0
- package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
- package/dist/utility/chart/chart-time-domain.util.js +23 -0
- package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
- package/dist/utility/chart/color-customization.leaf.js +16 -0
- package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
- package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
- package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
- package/dist/utility/chart/gesture-timing.leaf.js +29 -0
- package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
- package/dist/utility/chart/governed-contract-coin.util.js +39 -0
- package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
- package/dist/utility/chart/host-bar-placement.util.js +447 -0
- package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
- package/dist/utility/chart/index-host-tier.util.js +118 -0
- package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
- package/dist/utility/chart/index-mode-admission.util.js +67 -0
- package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
- package/dist/utility/chart/indicator-error-message.util.js +44 -0
- package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
- package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
- package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
- package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
- package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
- package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
- package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
- package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
- package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
- package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
- package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
- package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
- package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
- package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
- package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
- package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
- package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
- package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
- package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
- package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
- package/dist/utility/chart/kscript-source-retention.util.js +218 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
- package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
- package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
- package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
- package/dist/utility/chart/live-cadence.util.d.ts +38 -0
- package/dist/utility/chart/live-cadence.util.js +37 -0
- package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
- package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
- package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
- package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
- package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
- package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
- package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
- package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
- package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
- package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
- package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
- package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
- package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
- package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
- package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
- package/dist/utility/chart/mixed-mode.util.js +139 -0
- package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
- package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
- package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
- package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
- package/dist/utility/chart/price-precision.util.d.ts +40 -0
- package/dist/utility/chart/price-precision.util.js +70 -0
- package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
- package/dist/utility/chart/profile-block-size.util.js +141 -0
- package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
- package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
- package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
- package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
- package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
- package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
- package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
- package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
- package/dist/utility/chart/titan-constants.pin.js +18 -5
- package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
- package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
- package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
- package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
- package/dist/utility/chart/wrun-run-result.util.js +20 -14
- package/dist/utility/common/data-processing.util.d.ts +138 -0
- package/dist/utility/common/data-processing.util.js +346 -0
- package/dist/utility/common/visible-timeout.util.d.ts +13 -4
- package/dist/utility/common/visible-timeout.util.js +23 -8
- package/dist/utility/exchange-format.leaf.d.ts +1 -0
- package/dist/utility/exchange-format.leaf.js +47 -0
- package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
- package/dist/utility/market-events/earnings-scope.util.js +92 -0
- package/dist/utility/market-events/market-events.util.d.ts +147 -0
- package/dist/utility/market-events/market-events.util.js +392 -0
- package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
- package/dist/utility/market-events/zoned-clock.util.js +11 -0
- package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
- package/dist/utility/options/option-venue-disclosure.util.js +56 -0
- package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
- package/dist/utility/scriptEditor/package-semver.util.js +120 -0
- package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
- package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
- package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
- package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
- package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
- package/dist/utility/v2/governed-tier.leaf.js +113 -0
- package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
- package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
- package/dist/utility/wrun/sources/lanes/series.js +2 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
- package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
- package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
- package/dist/utility/wrun/wrun-bar-count.util.d.ts +83 -0
- package/dist/utility/wrun/wrun-bar-count.util.js +259 -0
- package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
- package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
- package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
- package/dist/utility/wrun/wrun-deadline.util.js +2 -1
- package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
- package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
- package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
- package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
- package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
- package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
- package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
- package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
- package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
- package/dist/utility/wrun/wrun-host.service.d.ts +266 -0
- package/dist/utility/wrun/wrun-host.service.js +655 -0
- package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
- package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
- package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
- package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
- package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
- package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
- package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
- package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
- package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
- package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
- package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
- package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
- package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
- package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
- package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
- package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
- package/dist/utility/wrun/wrun-param-map.util.js +40 -47
- package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
- package/dist/utility/wrun/wrun-param-values.util.js +5 -5
- package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
- package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
- package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
- package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
- package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
- package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
- package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
- package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
- package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
- package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
- package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
- package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
- package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
- package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
- package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
- package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
- package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
- package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
- package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
- package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
- package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
- package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
- package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
- package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
- package/dist/utility/wrun/wrun-text-params.util.js +19 -30
- package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
- package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
- package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
- package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
- package/dist/utility/wrun-alert-params.leaf.js +24 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
- package/dist/utils/replay/replay-buffer-math.js +684 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +190 -0
- package/dist/workers/wrun/wrun-abi-host.js +1201 -0
- package/dist/workers/wrun/wrun-engine-handler.d.ts +37 -0
- package/dist/workers/wrun/wrun-engine-handler.js +211 -0
- package/package.json +3 -3
|
@@ -0,0 +1,971 @@
|
|
|
1
|
+
import { getWrunOverlayLiveContext, hasWrunOverlayDriver, isWrunOverlayRerunInFlight, onWrunOverlayLiveTeardown, onWrunOverlayRunSettled, rerunWrunOverlayForChartWave, suspendWrunOverlayLiveSession, } from './wrun-overlay-drivers.util.js';
|
|
2
|
+
import { isWrunOverlayPausedError, isWrunQuarantinedError, isWrunVenueBlockedError, isWrunWorkerPoisonError, WrunChartGoneError, WrunWorkerPoisonError, } from './wrun-registry-errors.util.js';
|
|
3
|
+
import { attachWrunRefusal } from './wrun-refusal.util.js';
|
|
4
|
+
import { onGateSessionLatchChange } from '../v2/gate-session-latch.util.js';
|
|
5
|
+
import { __resetWrunGatePlaneReadersForTests, forgetWrunGatePlaneReader, wrunGatePlaneReaders, } from './wrun-gate-plane-readers.util.js';
|
|
6
|
+
import { overlayExecutionGuardKey } from '../chart/overlay-execution-guard-key.leaf.js';
|
|
7
|
+
import { LOCAL_ENGINE_SELF_HEAL_BASE_DELAY_MS, openLocalEngineSelfHealGate, recordLocalEngineSelfHealAttempt, } from '../chart/local-engine-self-heal-backoff.util.js';
|
|
8
|
+
import { KSCRIPT_SECONDARY_SOURCE_MAX_RECOVERY_ATTEMPTS, KSCRIPT_SECONDARY_SOURCE_RETRY_DELAYS_MS, } from '../chart/kscript-source-degrade.leaf.js';
|
|
9
|
+
import { isKScriptDisplayBlockedOnExchange, } from '../chart/kscript-venue-policy.util.js';
|
|
10
|
+
import { wrunRunFailedIdentityOf, wrunRunIdentityOf } from './wrun-cap-notice.util.js';
|
|
11
|
+
import { wrunChartHostEnv } from '../../host-env.js';
|
|
12
|
+
import { WRUN_RUN_FAILURE_ROW_CODES, wrunAbortRuntimeDiagnostic, wrunRunFailureRuntimeDiagnostic, } from '../scriptEditor/wrun-runtime-diagnostics.leaf.js';
|
|
13
|
+
import { bindWrunTransientRerunAdmission, claimWrunTransientRerun, isWrunTransientGracePending, isWrunTransientRerunOwed, oweWrunTransientRerun, requestWrunTransientRerun, takeWrunTransientOwedRerun, WRUN_SESSION_LOSS_TRIGGERS, } from './wrun-transient-rerun.util.js';
|
|
14
|
+
/** The loaded-range-refresh family: kScript skips a collapsed or pane-hidden
|
|
15
|
+
* script there (data-fetching.util isVisibleLocalTechnicalScript) and still
|
|
16
|
+
* computes it on a wave, so only these reasons hold on it. */
|
|
17
|
+
const COLLAPSED_HOLD_REASONS = new Set([
|
|
18
|
+
'resume',
|
|
19
|
+
'heal',
|
|
20
|
+
'budget-lift',
|
|
21
|
+
'loaded-range-refresh',
|
|
22
|
+
]);
|
|
23
|
+
/** The heal declines on these without asking the hold: the same run fails the same way (an author
|
|
24
|
+
* trap, a package quarantined past its first timeout), the venue wall refuses it, or it is paused. The row cap's refusal
|
|
25
|
+
* is not one of them: the hold's keyed latch declines it only while the heal would run the refused
|
|
26
|
+
* window with the refused settings, so a narrower window or other settings heal. */
|
|
27
|
+
const HEAL_DECLINED_FAILURES = new Set(['deterministic', 'venue', 'paused']);
|
|
28
|
+
/** A user rebuild retires a pending source rung: its own run is the attempt. */
|
|
29
|
+
const USER_REBUILD_REASONS = new Set(['settings', 'switch', 'retry', 'resume']);
|
|
30
|
+
/** The reasons the narrow deterministic latch holds: the waves and the heal that would run the
|
|
31
|
+
* same window again. A user rebuild (USER_REBUILD_REASONS) releases it instead. */
|
|
32
|
+
const LATCH_HOLD_REASONS = new Set([
|
|
33
|
+
'lazy-range-refresh',
|
|
34
|
+
'loaded-range-refresh',
|
|
35
|
+
'heal',
|
|
36
|
+
'budget-lift',
|
|
37
|
+
'live-rebuild',
|
|
38
|
+
]);
|
|
39
|
+
/** The settlement memory's latch (noteWrunRunSettled): per overlay, the identity of the last
|
|
40
|
+
* settled run the row cap refused. */
|
|
41
|
+
const failedLatches = new Map();
|
|
42
|
+
/** Rungs per degrade episode: kScript's ladder delays under its attempt cap. */
|
|
43
|
+
const SOURCE_RECOVERY_RUNGS = Math.min(KSCRIPT_SECONDARY_SOURCE_RETRY_DELAYS_MS.length, KSCRIPT_SECONDARY_SOURCE_MAX_RECOVERY_ATTEMPTS);
|
|
44
|
+
/** Collects the casualties of one worker death (their ticks report them a few
|
|
45
|
+
* microtasks apart) into one batch. */
|
|
46
|
+
const WRUN_CASUALTY_BATCH_MS = 100;
|
|
47
|
+
/** Gap between two casualty reseeds, so the respawned worker never takes every
|
|
48
|
+
* session's window in one burst. */
|
|
49
|
+
const WRUN_CASUALTY_STAGGER_MS = 250;
|
|
50
|
+
/** A second death of the same overlay inside this window parks it: the host's
|
|
51
|
+
* respawn window (wrun-host.service WRUN_WORKER_RESPAWN_WINDOW_MS). */
|
|
52
|
+
const WRUN_CASUALTY_WINDOW_MS = 60_000;
|
|
53
|
+
/** The host's run timeout, named in the parked chip's deadline sentence. */
|
|
54
|
+
const WRUN_CASUALTY_PARK_TIMEOUT_MS = 20_000;
|
|
55
|
+
function ring(event, details) {
|
|
56
|
+
if (wrunChartHostEnv().diagnostics.debugEnabled())
|
|
57
|
+
wrunChartHostEnv().diagnostics.debug(event, details);
|
|
58
|
+
}
|
|
59
|
+
let storeSide;
|
|
60
|
+
/** The store-side modules the hold reads, loaded on first use through the
|
|
61
|
+
* host's loaders (never at import) and shared by concurrent holds; a failed
|
|
62
|
+
* load is retried. */
|
|
63
|
+
function loadWrunStoreSide() {
|
|
64
|
+
storeSide ??= Promise.all([
|
|
65
|
+
wrunChartHostEnv().chart.loadChartStore(),
|
|
66
|
+
wrunChartHostEnv().chart.loadTitanCharts(),
|
|
67
|
+
wrunChartHostEnv().chart.loadChartMode(),
|
|
68
|
+
]).catch((error) => {
|
|
69
|
+
storeSide = undefined;
|
|
70
|
+
throw error;
|
|
71
|
+
});
|
|
72
|
+
return storeSide;
|
|
73
|
+
}
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// The run hold
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
/**
|
|
78
|
+
* Why a run of this overlay must not touch the chart now, first match wins;
|
|
79
|
+
* null means run. The kScript holds, read where kScript reads them: the pause
|
|
80
|
+
* flag and the execution guard (the guarded engine calls), replay (only the
|
|
81
|
+
* replay lane's run draws over replay rows), the ONE fetch gate (`isIndicatorGatedForFetch`:
|
|
82
|
+
* mode or pane budget), a collapsed or pane-hidden pane for the
|
|
83
|
+
* loaded-range-refresh family only, the CME display wall (the run head
|
|
84
|
+
* refuses it too; read here so a heal or a rung declines instead of spending
|
|
85
|
+
* a run), then the narrow deterministic latch for the waves and the heal
|
|
86
|
+
* (`failedDeterministicHold`). Null for an id with no driver, without loading
|
|
87
|
+
* the store.
|
|
88
|
+
*/
|
|
89
|
+
export async function wrunOverlayHold(chartIndex, indicatorId, reason,
|
|
90
|
+
/** The run the trigger would start: its window (absent = the whole loaded window), which the
|
|
91
|
+
* deterministic latch compares with the failed run's. */
|
|
92
|
+
candidate = {}) {
|
|
93
|
+
if (!hasWrunOverlayDriver(indicatorId))
|
|
94
|
+
return null;
|
|
95
|
+
// A person's rebuild (or a market switch) is a new attempt: the latch never outlives it.
|
|
96
|
+
if (USER_REBUILD_REASONS.has(reason))
|
|
97
|
+
failedLatches.delete(indicatorId);
|
|
98
|
+
const [{ useChartStore }, { getTC }, { isIndicatorGatedForFetch }] = await loadWrunStoreSide();
|
|
99
|
+
const chartStore = useChartStore();
|
|
100
|
+
if (chartStore.isKScriptOverlayPaused(chartIndex, indicatorId))
|
|
101
|
+
return 'paused';
|
|
102
|
+
if (wrunChartHostEnv().chart.isOverlayTripped(overlayExecutionGuardKey(chartIndex, indicatorId)))
|
|
103
|
+
return 'tripped';
|
|
104
|
+
// The replay lane's own run is what a replaying chart runs (it computes the
|
|
105
|
+
// replay's bars, wrun-replay-lane.util); outside replay it has nothing to do.
|
|
106
|
+
if (reason === 'replay') {
|
|
107
|
+
if (!wrunChartHostEnv().chart.isReplaying(chartIndex))
|
|
108
|
+
return 'replay-locked';
|
|
109
|
+
}
|
|
110
|
+
else if (wrunChartHostEnv().chart.isReplaying(chartIndex) ||
|
|
111
|
+
wrunChartHostEnv().chart.isReplayDataLocked(chartIndex)) {
|
|
112
|
+
return 'replay-locked';
|
|
113
|
+
}
|
|
114
|
+
if (isIndicatorGatedForFetch(chartIndex, indicatorId))
|
|
115
|
+
return 'gated';
|
|
116
|
+
const workspace = chartStore.mergedAllCharts[chartIndex];
|
|
117
|
+
const overlay = (workspace?.onchart ?? [])
|
|
118
|
+
.concat((workspace?.offchart ?? []))
|
|
119
|
+
.find((candidate) => candidate?.id === indicatorId);
|
|
120
|
+
const metas = getTC(chartIndex)?.metadata;
|
|
121
|
+
const meta = metas?.find((entry) => entry?.id === indicatorId);
|
|
122
|
+
if (COLLAPSED_HOLD_REASONS.has(reason) &&
|
|
123
|
+
(overlay?.isBottomPaneCollapsed === true || overlay?.isPaneHidden === true || meta?.isPaneHidden === true)) {
|
|
124
|
+
return 'collapsed';
|
|
125
|
+
}
|
|
126
|
+
// The run head's reading: the workspace's exchange against the mounted
|
|
127
|
+
// meta's settings (the persisted overlay's when the meta is not up yet).
|
|
128
|
+
const settings = (meta?.settings ?? overlay?.settings);
|
|
129
|
+
if (isKScriptDisplayBlockedOnExchange(workspace?.metadata?.exchange, settings))
|
|
130
|
+
return 'venue-blocked';
|
|
131
|
+
return failedDeterministicHold(indicatorId, reason, {
|
|
132
|
+
window: candidate.window,
|
|
133
|
+
mainRows: metas?.[0]?.rawData,
|
|
134
|
+
settings: meta?.settings,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The narrow deterministic latch (WRUN-COST-GUARD U4): the last settled run of this overlay was
|
|
139
|
+
* refused by the row cap (`FE_KSCRIPT_OUTPUT_OVERSIZED`), and the run a wave or the heal would start
|
|
140
|
+
* computes the same window with the same settings, so it would fail the same way: held. A narrower
|
|
141
|
+
* window (it may fit the rows) or other settings release the latch and run; a wider or moved window
|
|
142
|
+
* runs and its own settle decides.
|
|
143
|
+
*/
|
|
144
|
+
function failedDeterministicHold(indicatorId, reason, candidate) {
|
|
145
|
+
const latch = failedLatches.get(indicatorId);
|
|
146
|
+
if (latch === undefined || !LATCH_HOLD_REASONS.has(reason))
|
|
147
|
+
return null;
|
|
148
|
+
const identity = wrunRunIdentityOf(candidate);
|
|
149
|
+
if (identity === undefined)
|
|
150
|
+
return null;
|
|
151
|
+
if (identity.windowFirstTs === latch.windowFirstTs &&
|
|
152
|
+
identity.windowLastTs === latch.windowLastTs &&
|
|
153
|
+
identity.settingsSignature === latch.settingsSignature) {
|
|
154
|
+
return 'failed-deterministic';
|
|
155
|
+
}
|
|
156
|
+
const narrower = identity.windowFirstTs >= latch.windowFirstTs && identity.windowLastTs <= latch.windowLastTs;
|
|
157
|
+
if (narrower || identity.settingsSignature !== latch.settingsSignature)
|
|
158
|
+
failedLatches.delete(indicatorId);
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// Failure classes
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
/** The author's code failing (a trap, the output contract, the no-growth
|
|
165
|
+
* rule, an import the host cannot link): the test `wrunRuntimeTrapDiagnostic`
|
|
166
|
+
* applies (wrun-overlay-run.util), rebuilt from its leaf parts so this module
|
|
167
|
+
* stays out of the run util's graph. The run deadline is not one of them. */
|
|
168
|
+
function isWrunAuthorTrap(error) {
|
|
169
|
+
const message = error instanceof Error ? error.message : typeof error === 'string' ? error : '';
|
|
170
|
+
if (!message)
|
|
171
|
+
return false;
|
|
172
|
+
const row = wrunAbortRuntimeDiagnostic(message) ?? wrunRunFailureRuntimeDiagnostic(message);
|
|
173
|
+
return row !== null && WRUN_RUN_FAILURE_ROW_CODES.has(row.code);
|
|
174
|
+
}
|
|
175
|
+
/** A quarantine worth one more run once its hold ends: the package's FIRST
|
|
176
|
+
* run past the host's timeout (one slow run on a loaded host is not yet a
|
|
177
|
+
* pattern). A repeat, a worker crash, or a quarantine of unknown cause fails
|
|
178
|
+
* the same way again. */
|
|
179
|
+
function isFirstStrikeTimeoutQuarantine(error) {
|
|
180
|
+
return isWrunQuarantinedError(error) && error.reason === 'timeout' && error.strikes === 1;
|
|
181
|
+
}
|
|
182
|
+
/** The row cap's refusal (the preflight's `FE_KSCRIPT_OUTPUT_OVERSIZED`): rows cannot be trimmed
|
|
183
|
+
* without changing the plot, so the same run on the same window fails the same way. */
|
|
184
|
+
function isWrunOutputOversized(error) {
|
|
185
|
+
const message = error instanceof Error ? error.message : typeof error === 'string' ? error : '';
|
|
186
|
+
return message.includes('FE_KSCRIPT_OUTPUT_OVERSIZED');
|
|
187
|
+
}
|
|
188
|
+
/** A refusal the cloud keeps for good: the socket row source's `WrunSocketRefusalError`, which it
|
|
189
|
+
* makes only of a frame its code says to remember (`wrunFrameRefusalMemory`, wrun-hosted-wire-caps,
|
|
190
|
+
* the codes the protected worker remembers a refused create by). The same ask buys the same answer,
|
|
191
|
+
* so the heal parks it the way the protected repair lane parks a permanent refusal
|
|
192
|
+
* (noteProtectedKScriptPermanentRefusal). Read by name, as the C7 seam reads its transient error,
|
|
193
|
+
* so this module stays out of the socket source's graph. */
|
|
194
|
+
function isWrunPermanentCloudRefusal(error) {
|
|
195
|
+
return error instanceof Error && error.name === 'WrunSocketRefusalError';
|
|
196
|
+
}
|
|
197
|
+
/** How the heal treats a failed run: the venue wall and the pause hold have
|
|
198
|
+
* their own way out (leaving the venue, Resume); an author trap, a
|
|
199
|
+
* quarantined package, the row cap and a refusal the cloud keeps for good
|
|
200
|
+
* fail the same way again (the chip's Retry, an edit, a settings save or a
|
|
201
|
+
* narrower window is the way out), except a first-strike timeout quarantine,
|
|
202
|
+
* which the heal waits out and runs once more; everything else (deadline, no
|
|
203
|
+
* bars, a declined lane, a worker death, a transient source failure such as
|
|
204
|
+
* the cloud's market data being unavailable, another integration failure) is
|
|
205
|
+
* worth another run. */
|
|
206
|
+
export function classifyWrunRunFailure(error) {
|
|
207
|
+
const failure = wrunHealFailureOf(error);
|
|
208
|
+
return failure === 'row-budget' ? 'deterministic' : failure;
|
|
209
|
+
}
|
|
210
|
+
/** The class the heal keeps for a settled failure: the row cap's refusal apart ('row-budget': the
|
|
211
|
+
* keyed latch, not the class, decides whether the heal runs it again), else the public class with
|
|
212
|
+
* the first-strike quarantine wait (failureClassOfSettledRun). */
|
|
213
|
+
function wrunHealFailureOfSettledRun(indicatorId, error) {
|
|
214
|
+
if (isWrunOutputOversized(error))
|
|
215
|
+
return 'row-budget';
|
|
216
|
+
return failureClassOfSettledRun(indicatorId, error);
|
|
217
|
+
}
|
|
218
|
+
function wrunHealFailureOf(error) {
|
|
219
|
+
if (isWrunVenueBlockedError(error))
|
|
220
|
+
return 'venue';
|
|
221
|
+
if (isWrunOverlayPausedError(error))
|
|
222
|
+
return 'paused';
|
|
223
|
+
if (isWrunQuarantinedError(error))
|
|
224
|
+
return isFirstStrikeTimeoutQuarantine(error) ? 'retryable' : 'deterministic';
|
|
225
|
+
if (isWrunAuthorTrap(error))
|
|
226
|
+
return 'deterministic';
|
|
227
|
+
if (isWrunPermanentCloudRefusal(error))
|
|
228
|
+
return 'deterministic';
|
|
229
|
+
if (isWrunOutputOversized(error))
|
|
230
|
+
return 'row-budget';
|
|
231
|
+
return 'retryable';
|
|
232
|
+
}
|
|
233
|
+
// ---------------------------------------------------------------------------
|
|
234
|
+
// The heal ladder (a driver with no live session)
|
|
235
|
+
// ---------------------------------------------------------------------------
|
|
236
|
+
const healLadders = new Map();
|
|
237
|
+
const healEpisodes = new Map();
|
|
238
|
+
// One asynchronous tail per overlay; the token lets a teardown orphan it.
|
|
239
|
+
const healTails = new Map();
|
|
240
|
+
const failureClasses = new Map();
|
|
241
|
+
// Per overlay: when the first-strike timeout quarantine its heal waits out
|
|
242
|
+
// ends (epoch ms), before the one more run it is owed. Kept until a run
|
|
243
|
+
// settles ok, so a later quarantine (the owed run spun again) is final even
|
|
244
|
+
// where the host's ladder started the package over at one strike.
|
|
245
|
+
const quarantineWaits = new Map();
|
|
246
|
+
/**
|
|
247
|
+
* A live session the heal leaves alone: a registered live context, unless a
|
|
248
|
+
* failed reopen holds it (`liveSuspendedBy: 'reopen-failed'`: the reseed's
|
|
249
|
+
* one full run failed too and keep-last-good kept the context; for a session
|
|
250
|
+
* a row source feeds, the session that fed it is known gone: a failed create
|
|
251
|
+
* that reached the cloud replaced it, or the kScript socket's reconnect or
|
|
252
|
+
* session sweep said the worker lost it, whatever its rebuild did since).
|
|
253
|
+
* That one is idle to the heal like a driver with no session, so a retryable
|
|
254
|
+
* failure is retried on the dwell and backoff and a deterministic one is
|
|
255
|
+
* declined. A budget hold stays healthy here: a heal run over the same window
|
|
256
|
+
* would be refused again.
|
|
257
|
+
*/
|
|
258
|
+
function hasHealthyWrunLiveSession(indicatorId) {
|
|
259
|
+
const context = getWrunOverlayLiveContext(indicatorId);
|
|
260
|
+
return context !== undefined && context.liveSuspendedBy !== 'reopen-failed';
|
|
261
|
+
}
|
|
262
|
+
/** Reset the heal for one overlay: the backoff ladder, the idle episode, the
|
|
263
|
+
* last failure class with its latch and a quarantine wait (a run settled ok,
|
|
264
|
+
* Resume, a teardown). */
|
|
265
|
+
export function resetWrunOverlayHealLadder(indicatorId) {
|
|
266
|
+
healLadders.delete(indicatorId);
|
|
267
|
+
healEpisodes.delete(indicatorId);
|
|
268
|
+
failureClasses.delete(indicatorId);
|
|
269
|
+
quarantineWaits.delete(indicatorId);
|
|
270
|
+
failedLatches.delete(indicatorId);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Look at an overlay a steady-state signal found idle (a poll, a live frame,
|
|
274
|
+
* a wake, a show; the live tick forwards these for a session a failed reopen
|
|
275
|
+
* holds). The synchronous verdict tells the caller who owns the overlay:
|
|
276
|
+
* 'no-driver' (not a wrun overlay, the caller continues on its own line),
|
|
277
|
+
* 'healthy' (a live session runs, or a budget holds it), 'in-flight' (a run
|
|
278
|
+
* or the add's first-run attempt is open: its outcome decides, and a failed
|
|
279
|
+
* run starts a fresh dwell), 'queued' (the asynchronous tail below decides:
|
|
280
|
+
* dwell, backoff, declines, then at most one heal run).
|
|
281
|
+
*/
|
|
282
|
+
export function healWrunOverlayIfIdle(chartIndex, indicatorId, signal) {
|
|
283
|
+
if (!hasWrunOverlayDriver(indicatorId))
|
|
284
|
+
return 'no-driver';
|
|
285
|
+
if (hasHealthyWrunLiveSession(indicatorId)) {
|
|
286
|
+
healEpisodes.delete(indicatorId);
|
|
287
|
+
return 'healthy';
|
|
288
|
+
}
|
|
289
|
+
if (isWrunOverlayRerunInFlight(indicatorId) ||
|
|
290
|
+
wrunChartHostEnv().diagnostics.liveAttemptToken(chartIndex, indicatorId) !== null) {
|
|
291
|
+
healEpisodes.delete(indicatorId);
|
|
292
|
+
return 'in-flight';
|
|
293
|
+
}
|
|
294
|
+
if (!healTails.has(indicatorId)) {
|
|
295
|
+
const token = Symbol(indicatorId);
|
|
296
|
+
healTails.set(indicatorId, token);
|
|
297
|
+
void runWrunHealTail(chartIndex, indicatorId, signal, token)
|
|
298
|
+
.catch((error) => {
|
|
299
|
+
ring('wrun-overlay-self-heal-failed', {
|
|
300
|
+
chartIndex,
|
|
301
|
+
indicatorId,
|
|
302
|
+
signal,
|
|
303
|
+
error: error instanceof Error ? error.message : String(error),
|
|
304
|
+
});
|
|
305
|
+
})
|
|
306
|
+
.finally(() => {
|
|
307
|
+
if (healTails.get(indicatorId) === token)
|
|
308
|
+
healTails.delete(indicatorId);
|
|
309
|
+
scheduleWrunTransientOwedRerun(chartIndex, indicatorId);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return 'queued';
|
|
313
|
+
}
|
|
314
|
+
/** Still this overlay's tail, and the overlay still a driver with no healthy
|
|
315
|
+
* session and no run open (rechecked after every await). */
|
|
316
|
+
function healTailCurrent(chartIndex, indicatorId, token) {
|
|
317
|
+
return (healTails.get(indicatorId) === token &&
|
|
318
|
+
hasWrunOverlayDriver(indicatorId) &&
|
|
319
|
+
!hasHealthyWrunLiveSession(indicatorId) &&
|
|
320
|
+
!isWrunOverlayRerunInFlight(indicatorId) &&
|
|
321
|
+
wrunChartHostEnv().diagnostics.liveAttemptToken(chartIndex, indicatorId) === null);
|
|
322
|
+
}
|
|
323
|
+
async function runWrunHealTail(chartIndex, indicatorId, signal, token) {
|
|
324
|
+
const nowMs = Date.now();
|
|
325
|
+
const report = (verdict, details = {}) => ring('wrun-overlay-self-heal', {
|
|
326
|
+
chartIndex,
|
|
327
|
+
indicatorId,
|
|
328
|
+
signal,
|
|
329
|
+
verdict,
|
|
330
|
+
attempt: healLadders.get(indicatorId)?.attempts ?? 0,
|
|
331
|
+
...details,
|
|
332
|
+
});
|
|
333
|
+
// The dwell: a steady signal (poll, live frame) heals only after the
|
|
334
|
+
// overlay stayed idle a while, so the short gap between a mount and its
|
|
335
|
+
// first run never triggers it. A wake or a show is one discrete event.
|
|
336
|
+
if (signal === 'poll' || signal === 'live-frame') {
|
|
337
|
+
const { LOCAL_ENGINE_UNINIT_HEAL_DWELL_MS, noteIdleUninitializedSignal } = await import('../chart/local-engine-uninit.leaf.js');
|
|
338
|
+
if (!healTailCurrent(chartIndex, indicatorId, token))
|
|
339
|
+
return;
|
|
340
|
+
const episode = noteIdleUninitializedSignal(healEpisodes.get(indicatorId), nowMs);
|
|
341
|
+
healEpisodes.set(indicatorId, episode);
|
|
342
|
+
const idleMs = nowMs - episode.firstSeenAtMs;
|
|
343
|
+
if (idleMs < LOCAL_ENGINE_UNINIT_HEAL_DWELL_MS) {
|
|
344
|
+
report('dwell', { idleMs, nextDelayMs: LOCAL_ENGINE_UNINIT_HEAL_DWELL_MS - idleMs });
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// A first-strike timeout quarantine: the host refuses the package until its
|
|
349
|
+
// hold ends, so the heal waits it out without spending a rung, then runs it
|
|
350
|
+
// once more.
|
|
351
|
+
const quarantinedUntil = quarantineWaits.get(indicatorId);
|
|
352
|
+
if (quarantinedUntil !== undefined && nowMs < quarantinedUntil) {
|
|
353
|
+
report('held', { cause: 'quarantine', nextDelayMs: quarantinedUntil - nowMs });
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const ladder = healLadders.get(indicatorId);
|
|
357
|
+
const gate = openLocalEngineSelfHealGate(ladder, nowMs);
|
|
358
|
+
if (!gate) {
|
|
359
|
+
report('held', { nextDelayMs: Math.max(0, (ladder?.nextEligibleAtMs ?? nowMs) - nowMs) });
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
// Re-armed at the base hold: every decline below re-checks one base hold
|
|
363
|
+
// later without escalating the ladder (the backoff util's semantics).
|
|
364
|
+
healLadders.set(indicatorId, gate);
|
|
365
|
+
const failure = failureClasses.get(indicatorId);
|
|
366
|
+
if (failure !== undefined && HEAL_DECLINED_FAILURES.has(failure)) {
|
|
367
|
+
report('declined', { cause: failure, nextDelayMs: LOCAL_ENGINE_SELF_HEAL_BASE_DELAY_MS });
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
// A row-cap refusal ('row-budget') reaches the hold: its keyed latch compares the heal's run (the
|
|
371
|
+
// whole loaded window, the mounted settings) with the refused one and declines only the same.
|
|
372
|
+
const hold = await wrunOverlayHold(chartIndex, indicatorId, 'heal');
|
|
373
|
+
if (!healTailCurrent(chartIndex, indicatorId, token))
|
|
374
|
+
return;
|
|
375
|
+
if (hold !== null) {
|
|
376
|
+
report('declined', { cause: hold, nextDelayMs: LOCAL_ENGINE_SELF_HEAL_BASE_DELAY_MS });
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
// Inside a transient grace this run, on the ladder's own cadence (its dwell, its backoff), is the grace's 'heal'
|
|
380
|
+
// trigger: it spends it, once per grace like every trigger (CLOUD-RUN-ROBUST C5).
|
|
381
|
+
const target = { chartIndex, indicatorId };
|
|
382
|
+
if (isWrunTransientGracePending(target) && !claimWrunTransientRerun(target, 'heal')) {
|
|
383
|
+
report('declined', { cause: 'grace-heal-spent', nextDelayMs: LOCAL_ENGINE_SELF_HEAL_BASE_DELAY_MS });
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
const work = rerunWrunOverlayForChartWave(indicatorId, { reason: 'heal' });
|
|
387
|
+
if (!work) {
|
|
388
|
+
report('skipped', { nextDelayMs: LOCAL_ENGINE_SELF_HEAL_BASE_DELAY_MS });
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
// Only a run that actually started counts as an attempt on the ladder; it
|
|
392
|
+
// is recorded before the run settles, so a success resets it after.
|
|
393
|
+
const healAttempt = recordLocalEngineSelfHealAttempt(healLadders.get(indicatorId) ?? gate, Date.now());
|
|
394
|
+
healLadders.set(indicatorId, healAttempt.state);
|
|
395
|
+
report('attempt', { attempt: healAttempt.attempt, nextDelayMs: healAttempt.delayMs });
|
|
396
|
+
void work.catch(() => undefined);
|
|
397
|
+
}
|
|
398
|
+
// ---------------------------------------------------------------------------
|
|
399
|
+
// The transient grace's reruns (CLOUD-RUN-ROBUST C5)
|
|
400
|
+
// ---------------------------------------------------------------------------
|
|
401
|
+
/**
|
|
402
|
+
* The one admission of a transient grace's rerun (wrun-transient-rerun.util `requestWrunTransientRerun`, bound
|
|
403
|
+
* below): the heal's entry for an overlay whose refusal waits out its grace, asked by the event that may have ended
|
|
404
|
+
* its condition. Deduped against the overlay's own work, whose outcome decides (a paint retracts the refusal, another
|
|
405
|
+
* transient failure stays inside the same grace): a run in flight or queued behind one, or the add's first-run
|
|
406
|
+
* attempt still open ('in-flight'), a heal or rerun tail deciding ('queued'); the event is then owed one coalesced
|
|
407
|
+
* rerun once that work settles without a paint (`scheduleWrunTransientOwedRerun`). Each trigger admits once per grace
|
|
408
|
+
* ('spent' once it did, or with no grace waiting); an ask deduped here spends nothing, so the same event later in the
|
|
409
|
+
* grace may still admit. The admitted tail of an event skips the heal's dwell and backoff (the event may have ended the
|
|
410
|
+
* condition; the grace bounds it) and keeps the heal's declines and the run hold. The heal ladder's own look keeps its
|
|
411
|
+
* cadence inside a grace: its run is the grace's 'heal' trigger (runWrunHealTail spends it).
|
|
412
|
+
*/
|
|
413
|
+
function admitWrunTransientRerun(target, trigger) {
|
|
414
|
+
const { chartIndex, indicatorId } = target;
|
|
415
|
+
if (!hasWrunOverlayDriver(indicatorId))
|
|
416
|
+
return 'no-driver';
|
|
417
|
+
// The overlay's own work decides first; an event it met is owed one rerun once that work settles unpainted.
|
|
418
|
+
if (isWrunOverlayRerunInFlight(indicatorId) ||
|
|
419
|
+
wrunChartHostEnv().diagnostics.liveAttemptToken(chartIndex, indicatorId) !== null) {
|
|
420
|
+
oweWrunTransientRerun(target, trigger);
|
|
421
|
+
return 'in-flight';
|
|
422
|
+
}
|
|
423
|
+
if (healTails.has(indicatorId)) {
|
|
424
|
+
oweWrunTransientRerun(target, trigger);
|
|
425
|
+
return 'queued';
|
|
426
|
+
}
|
|
427
|
+
if (!claimWrunTransientRerun(target, trigger))
|
|
428
|
+
return 'spent';
|
|
429
|
+
// The heal's tail slot: a heal look or another trigger arriving meanwhile coalesces with this tail.
|
|
430
|
+
const token = Symbol(indicatorId);
|
|
431
|
+
healTails.set(indicatorId, token);
|
|
432
|
+
void runWrunTransientRerunTail(chartIndex, indicatorId, trigger, token)
|
|
433
|
+
.catch((error) => {
|
|
434
|
+
ring('wrun-transient-rerun-failed', {
|
|
435
|
+
chartIndex,
|
|
436
|
+
indicatorId,
|
|
437
|
+
trigger,
|
|
438
|
+
error: error instanceof Error ? error.message : String(error),
|
|
439
|
+
});
|
|
440
|
+
})
|
|
441
|
+
.finally(() => {
|
|
442
|
+
if (healTails.get(indicatorId) === token)
|
|
443
|
+
healTails.delete(indicatorId);
|
|
444
|
+
scheduleWrunTransientOwedRerun(chartIndex, indicatorId);
|
|
445
|
+
});
|
|
446
|
+
return 'admitted';
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The overlay's own work settled (a run's settle, a heal or rerun tail's end): the rerun its grace owes an event that
|
|
450
|
+
* met that work runs once, through the one admission. On the next task, once the executor decided the settled run's
|
|
451
|
+
* follow-up: a follow-up in flight owes it again, to its own settle. A paint, the grace's end or a teardown before
|
|
452
|
+
* then took the owed rerun with the grace.
|
|
453
|
+
*/
|
|
454
|
+
function scheduleWrunTransientOwedRerun(chartIndex, indicatorId) {
|
|
455
|
+
const target = { chartIndex, indicatorId };
|
|
456
|
+
if (!isWrunTransientRerunOwed(target))
|
|
457
|
+
return;
|
|
458
|
+
setTimeout(() => {
|
|
459
|
+
const owed = takeWrunTransientOwedRerun(target);
|
|
460
|
+
if (owed !== undefined)
|
|
461
|
+
requestWrunTransientRerun(target, owed);
|
|
462
|
+
}, 0);
|
|
463
|
+
}
|
|
464
|
+
/** Still this overlay's tail, and the overlay still a driver with no run open (rechecked after every await). */
|
|
465
|
+
function transientTailCurrent(chartIndex, indicatorId, token) {
|
|
466
|
+
return (healTails.get(indicatorId) === token &&
|
|
467
|
+
hasWrunOverlayDriver(indicatorId) &&
|
|
468
|
+
!isWrunOverlayRerunInFlight(indicatorId) &&
|
|
469
|
+
wrunChartHostEnv().diagnostics.liveAttemptToken(chartIndex, indicatorId) === null);
|
|
470
|
+
}
|
|
471
|
+
/** The admitted rerun: the heal's declines (a failure class that fails the same way, the venue wall, a pause), the
|
|
472
|
+
* run hold for its reason, then one run through the executor: a 'live-rebuild' when the session is gone, else a
|
|
473
|
+
* 'heal'. */
|
|
474
|
+
async function runWrunTransientRerunTail(chartIndex, indicatorId, trigger, token) {
|
|
475
|
+
const reason = WRUN_SESSION_LOSS_TRIGGERS.has(trigger) ? 'live-rebuild' : 'heal';
|
|
476
|
+
const report = (verdict, details = {}) => ring('wrun-transient-rerun', { chartIndex, indicatorId, trigger, reason, verdict, ...details });
|
|
477
|
+
const failure = failureClasses.get(indicatorId);
|
|
478
|
+
if (failure !== undefined && HEAL_DECLINED_FAILURES.has(failure)) {
|
|
479
|
+
report('declined', { cause: failure });
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const hold = await wrunOverlayHold(chartIndex, indicatorId, reason);
|
|
483
|
+
if (!transientTailCurrent(chartIndex, indicatorId, token))
|
|
484
|
+
return;
|
|
485
|
+
if (hold !== null) {
|
|
486
|
+
report('held', { cause: hold });
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const work = rerunWrunOverlayForChartWave(indicatorId, { reason });
|
|
490
|
+
if (!work) {
|
|
491
|
+
report('skipped');
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
report('rerun');
|
|
495
|
+
void work.catch(() => undefined);
|
|
496
|
+
}
|
|
497
|
+
const sourceRecoveries = new Map();
|
|
498
|
+
// Settled executor runs per overlay. Runs are single flight per overlay, so an
|
|
499
|
+
// arming whose count equals the current one happened inside the run settling now.
|
|
500
|
+
const settledRuns = new Map();
|
|
501
|
+
/**
|
|
502
|
+
* A run treated these lanes as empty instead of failing (the run's degrade):
|
|
503
|
+
* arm kScript's recovery rungs for the retryable ones. A rung is one whole
|
|
504
|
+
* run (`reason: 'source-recovery'`; the lanes ride the fetch cache and the
|
|
505
|
+
* executor's single flight); a hold re-arms the same step; a run that lands
|
|
506
|
+
* every lane retires the episode ('recovered', from the run); after the last
|
|
507
|
+
* 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.
|
|
509
|
+
*/
|
|
510
|
+
export function armWrunSourceRecovery(chartIndex, indicatorId, degraded) {
|
|
511
|
+
if (!hasWrunOverlayDriver(indicatorId))
|
|
512
|
+
return;
|
|
513
|
+
// A non-retryable degrade is terminal on its own (the registry marks it so).
|
|
514
|
+
const retryable = degraded.filter((lane) => lane.retryable);
|
|
515
|
+
if (retryable.length === 0)
|
|
516
|
+
return;
|
|
517
|
+
let recovery = sourceRecoveries.get(indicatorId);
|
|
518
|
+
if (!recovery) {
|
|
519
|
+
recovery = {
|
|
520
|
+
chartIndex,
|
|
521
|
+
lanes: new Map(),
|
|
522
|
+
step: 0,
|
|
523
|
+
timer: undefined,
|
|
524
|
+
running: false,
|
|
525
|
+
terminal: false,
|
|
526
|
+
armedAtSettle: 0,
|
|
527
|
+
lastArmed: [],
|
|
528
|
+
};
|
|
529
|
+
sourceRecoveries.set(indicatorId, recovery);
|
|
530
|
+
}
|
|
531
|
+
recovery.chartIndex = chartIndex;
|
|
532
|
+
recovery.lanes = new Map(retryable.map((lane) => [lane.lane, lane]));
|
|
533
|
+
recovery.armedAtSettle = settledRuns.get(indicatorId) ?? 0;
|
|
534
|
+
recovery.lastArmed = retryable;
|
|
535
|
+
if (recovery.terminal) {
|
|
536
|
+
// The run re-marked them degraded and retryable: nothing more will be
|
|
537
|
+
// tried this episode, so the chip must not promise it.
|
|
538
|
+
markWrunSourcesTerminal(indicatorId, recovery);
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (recovery.timer !== undefined || recovery.running)
|
|
542
|
+
return;
|
|
543
|
+
scheduleWrunSourceRung(indicatorId, recovery);
|
|
544
|
+
}
|
|
545
|
+
/** Drop one overlay's source ladder: every lane landed ('recovered'), a user
|
|
546
|
+
* rebuild took over ('rebuild'), or the overlay left ('teardown'). */
|
|
547
|
+
export function retireWrunSourceRecovery(indicatorId, cause) {
|
|
548
|
+
const recovery = sourceRecoveries.get(indicatorId);
|
|
549
|
+
if (!recovery)
|
|
550
|
+
return;
|
|
551
|
+
if (recovery.timer !== undefined)
|
|
552
|
+
clearTimeout(recovery.timer);
|
|
553
|
+
recovery.timer = undefined;
|
|
554
|
+
sourceRecoveries.delete(indicatorId);
|
|
555
|
+
ring('wrun-source-recovery-retired', { chartIndex: recovery.chartIndex, indicatorId, cause, step: recovery.step });
|
|
556
|
+
}
|
|
557
|
+
function markWrunSourcesTerminal(indicatorId, recovery) {
|
|
558
|
+
recovery.terminal = true;
|
|
559
|
+
wrunChartHostEnv().chart.markSourcesTerminal(overlayExecutionGuardKey(recovery.chartIndex, indicatorId), [
|
|
560
|
+
...recovery.lanes.keys(),
|
|
561
|
+
]);
|
|
562
|
+
}
|
|
563
|
+
function scheduleWrunSourceRung(indicatorId, recovery) {
|
|
564
|
+
if (recovery.step >= SOURCE_RECOVERY_RUNGS) {
|
|
565
|
+
markWrunSourcesTerminal(indicatorId, recovery);
|
|
566
|
+
ring('wrun-source-recovery-terminal', {
|
|
567
|
+
chartIndex: recovery.chartIndex,
|
|
568
|
+
indicatorId,
|
|
569
|
+
lanes: [...recovery.lanes.keys()],
|
|
570
|
+
attempts: recovery.step,
|
|
571
|
+
});
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
const delayMs = KSCRIPT_SECONDARY_SOURCE_RETRY_DELAYS_MS[recovery.step];
|
|
575
|
+
recovery.timer = setTimeout(() => {
|
|
576
|
+
recovery.timer = undefined;
|
|
577
|
+
void runWrunSourceRung(indicatorId, recovery).catch((error) => {
|
|
578
|
+
console.warn(`[wrun] source recovery rung failed for '${indicatorId}':`, error);
|
|
579
|
+
});
|
|
580
|
+
}, delayMs);
|
|
581
|
+
}
|
|
582
|
+
async function runWrunSourceRung(indicatorId, recovery) {
|
|
583
|
+
const current = () => sourceRecoveries.get(indicatorId) === recovery && recovery.timer === undefined;
|
|
584
|
+
if (!current())
|
|
585
|
+
return;
|
|
586
|
+
const hold = await wrunOverlayHold(recovery.chartIndex, indicatorId, 'source-recovery');
|
|
587
|
+
if (!current())
|
|
588
|
+
return;
|
|
589
|
+
if (hold !== null) {
|
|
590
|
+
ring('wrun-source-recovery-held', { chartIndex: recovery.chartIndex, indicatorId, hold, step: recovery.step });
|
|
591
|
+
scheduleWrunSourceRung(indicatorId, recovery);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
recovery.step += 1;
|
|
595
|
+
ring('wrun-source-recovery-rung', {
|
|
596
|
+
chartIndex: recovery.chartIndex,
|
|
597
|
+
indicatorId,
|
|
598
|
+
attempt: recovery.step,
|
|
599
|
+
lanes: [...recovery.lanes.keys()],
|
|
600
|
+
});
|
|
601
|
+
const work = rerunWrunOverlayForChartWave(indicatorId, { reason: 'source-recovery' });
|
|
602
|
+
if (work) {
|
|
603
|
+
recovery.running = true;
|
|
604
|
+
try {
|
|
605
|
+
await work;
|
|
606
|
+
}
|
|
607
|
+
catch {
|
|
608
|
+
// The executor keeps the last good result; the next step decides.
|
|
609
|
+
}
|
|
610
|
+
finally {
|
|
611
|
+
recovery.running = false;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
// The rung's run re-armed (the timer is set), retired (recovered) or left
|
|
615
|
+
// the lanes as they were (failed before the lanes): the next step decides.
|
|
616
|
+
if (sourceRecoveries.get(indicatorId) !== recovery || recovery.timer !== undefined || recovery.terminal)
|
|
617
|
+
return;
|
|
618
|
+
scheduleWrunSourceRung(indicatorId, recovery);
|
|
619
|
+
}
|
|
620
|
+
// ---------------------------------------------------------------------------
|
|
621
|
+
// The gate session (another screen holds a plane's one session)
|
|
622
|
+
// ---------------------------------------------------------------------------
|
|
623
|
+
/**
|
|
624
|
+
* The latch's edge (gate-session-latch.util, published by the plane's owner): every overlay whose latest full run read
|
|
625
|
+
* the plane (wrun-options-stop.util `wrunGatePlaneReaders`) runs again, each through its hold, after the owner's own
|
|
626
|
+
* call returns (a rerun never runs inside the gate's kick or resume). Once another screen takes the session the run
|
|
627
|
+
* stops those lanes at dispatch and says why (`options-stopped` `session-elsewhere`, with Resume here); once this tab
|
|
628
|
+
* takes it back (the handoff's Resume here or the chip's) they read again. No timer re-asks a stopped lane: only the
|
|
629
|
+
* take-back can serve it.
|
|
630
|
+
*/
|
|
631
|
+
export function rerunWrunGatePlaneReaders(plane, heldElsewhere) {
|
|
632
|
+
const readers = wrunGatePlaneReaders(plane);
|
|
633
|
+
if (readers.length === 0)
|
|
634
|
+
return;
|
|
635
|
+
// The take-back is the user's own claim; the latch is the gate's.
|
|
636
|
+
const reason = heldElsewhere ? 'source-recovery' : 'retry';
|
|
637
|
+
ring('wrun-gate-session-rerun', { plane, heldElsewhere, overlays: readers.map((reader) => reader.indicatorId) });
|
|
638
|
+
setTimeout(() => {
|
|
639
|
+
for (const { indicatorId, chartIndex } of readers) {
|
|
640
|
+
if (!hasWrunOverlayDriver(indicatorId)) {
|
|
641
|
+
forgetWrunGatePlaneReader(indicatorId);
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
void wrunOverlayHold(chartIndex, indicatorId, reason)
|
|
645
|
+
.then((hold) => (hold !== null ? undefined : rerunWrunOverlayForChartWave(indicatorId, { reason })))
|
|
646
|
+
.catch(() => undefined);
|
|
647
|
+
}
|
|
648
|
+
}, 0);
|
|
649
|
+
}
|
|
650
|
+
// ---------------------------------------------------------------------------
|
|
651
|
+
// Settled runs
|
|
652
|
+
// ---------------------------------------------------------------------------
|
|
653
|
+
/** The class a failed run leaves for the heal. A first-strike timeout
|
|
654
|
+
* quarantine is retryable once per overlay: its hold end is kept for the
|
|
655
|
+
* heal's wait, and a quarantine with another hold end (the owed run spun
|
|
656
|
+
* again) is deterministic. */
|
|
657
|
+
function failureClassOfSettledRun(indicatorId, error) {
|
|
658
|
+
const failure = classifyWrunRunFailure(error);
|
|
659
|
+
if (failure !== 'retryable' || !isWrunQuarantinedError(error))
|
|
660
|
+
return failure;
|
|
661
|
+
const waited = quarantineWaits.get(indicatorId);
|
|
662
|
+
if (waited !== undefined && waited !== error.until)
|
|
663
|
+
return 'deterministic';
|
|
664
|
+
quarantineWaits.set(indicatorId, error.until);
|
|
665
|
+
return failure;
|
|
666
|
+
}
|
|
667
|
+
/** A run the overlay's own newer intent superseded (CLOUD-RUN-ROBUST C4): the run pass settles it `dropped`, as the
|
|
668
|
+
* quiet chart-gone error whose cause is 'superseded'. Read structurally (the run util's `isWrunRunDroppedError` is
|
|
669
|
+
* the same test), so this module stays out of the run util's graph. */
|
|
670
|
+
function isWrunRunDroppedSettle(error) {
|
|
671
|
+
return error instanceof WrunChartGoneError && error.cause === 'superseded';
|
|
672
|
+
}
|
|
673
|
+
function noteWrunRunSettled(event) {
|
|
674
|
+
const { indicatorId } = event;
|
|
675
|
+
// A run settling after its overlay's teardown leaves nothing behind.
|
|
676
|
+
if (!hasWrunOverlayDriver(indicatorId))
|
|
677
|
+
return;
|
|
678
|
+
// A dropped run is no outcome of the overlay (its replacement's settle is): it leaves the heal's failure class and
|
|
679
|
+
// the latch as they were, so it neither strikes nor clears either. It still counts as a settled run below.
|
|
680
|
+
if (event.ok || !isWrunRunDroppedSettle(event.error)) {
|
|
681
|
+
if (event.ok)
|
|
682
|
+
resetWrunOverlayHealLadder(indicatorId);
|
|
683
|
+
else
|
|
684
|
+
failureClasses.set(indicatorId, wrunHealFailureOfSettledRun(indicatorId, event.error));
|
|
685
|
+
// The latch keeps the identity of a run the row cap refused (the event's, else the one its
|
|
686
|
+
// rejection carries); every other settle releases it, so it never outlives a different outcome.
|
|
687
|
+
const identity = event.ok ? undefined : (event.failedIdentity ?? wrunRunFailedIdentityOf(event.error));
|
|
688
|
+
if (identity !== undefined && isWrunOutputOversized(event.error))
|
|
689
|
+
failedLatches.set(indicatorId, identity);
|
|
690
|
+
else
|
|
691
|
+
failedLatches.delete(indicatorId);
|
|
692
|
+
}
|
|
693
|
+
const settled = settledRuns.get(indicatorId) ?? 0;
|
|
694
|
+
if (USER_REBUILD_REASONS.has(event.reason)) {
|
|
695
|
+
const recovery = sourceRecoveries.get(indicatorId);
|
|
696
|
+
if (recovery) {
|
|
697
|
+
// The rebuild's own run is the attempt and resets the episode; when that
|
|
698
|
+
// run degraded the lanes again (it armed during the run), its degrade
|
|
699
|
+
// starts a fresh episode at the first rung.
|
|
700
|
+
const armedByThisRun = recovery.armedAtSettle === settled;
|
|
701
|
+
const { chartIndex, lastArmed } = recovery;
|
|
702
|
+
retireWrunSourceRecovery(indicatorId, 'rebuild');
|
|
703
|
+
if (armedByThisRun)
|
|
704
|
+
armWrunSourceRecovery(chartIndex, indicatorId, lastArmed);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
settledRuns.set(indicatorId, settled + 1);
|
|
708
|
+
// A run settled without a paint (a paint ended the grace, and the owed rerun with it): the rerun an event that met
|
|
709
|
+
// it is owed runs now.
|
|
710
|
+
scheduleWrunTransientOwedRerun(event.chartIndex, indicatorId);
|
|
711
|
+
}
|
|
712
|
+
// Per overlay: the last death the window counts from, its chart (read from the
|
|
713
|
+
// live context while it still stands), and the reseed waiting for its turn
|
|
714
|
+
// (its casualty record).
|
|
715
|
+
const casualtyDeaths = new Map();
|
|
716
|
+
const casualtyCharts = new Map();
|
|
717
|
+
const casualtyQueue = new Map();
|
|
718
|
+
const casualtyStaggers = new Map();
|
|
719
|
+
let casualtyBatchTimer;
|
|
720
|
+
/**
|
|
721
|
+
* The overlays a worker death took down (the tick's poison branch, a reseed
|
|
722
|
+
* that died again), with the host's record of that death (the poison error's
|
|
723
|
+
* `death`; a rejection that carries none is a death whose holder nobody
|
|
724
|
+
* knows). A first death joins one short batch whose reseeds are staggered
|
|
725
|
+
* (`reseedWrunOverlayFromBuffers(id, 'session-lost')`, no fetch; a session the
|
|
726
|
+
* buffers cannot reopen goes to the full-run driver, the tick's rule). A
|
|
727
|
+
* second death of the same overlay inside the casualty window parks it: its
|
|
728
|
+
* live session is suspended, its legend chip shows the run deadline (the
|
|
729
|
+
* retryable data chip) in words that name this death, and the heal ladder
|
|
730
|
+
* owns it from there. A report for an overlay whose reseed is still waiting
|
|
731
|
+
* is the same death.
|
|
732
|
+
*/
|
|
733
|
+
export function requestWrunCasualtyRebuilds(indicatorIds, death) {
|
|
734
|
+
const nowMs = Date.now();
|
|
735
|
+
const cause = death ?? Object.freeze({ kind: 'unknown', at: nowMs });
|
|
736
|
+
let queued = false;
|
|
737
|
+
for (const indicatorId of indicatorIds) {
|
|
738
|
+
if (!hasWrunOverlayDriver(indicatorId))
|
|
739
|
+
continue;
|
|
740
|
+
if (casualtyQueue.has(indicatorId) || casualtyStaggers.has(indicatorId))
|
|
741
|
+
continue;
|
|
742
|
+
const liveChartIndex = getWrunOverlayLiveContext(indicatorId)?.chartIndex;
|
|
743
|
+
if (liveChartIndex !== undefined)
|
|
744
|
+
casualtyCharts.set(indicatorId, liveChartIndex);
|
|
745
|
+
const casualty = Object.freeze({
|
|
746
|
+
indicatorId,
|
|
747
|
+
chartIndex: casualtyCharts.get(indicatorId),
|
|
748
|
+
death: cause,
|
|
749
|
+
});
|
|
750
|
+
const lastDeathAt = casualtyDeaths.get(indicatorId);
|
|
751
|
+
if (lastDeathAt !== undefined && nowMs - lastDeathAt < WRUN_CASUALTY_WINDOW_MS) {
|
|
752
|
+
parkWrunCasualty(casualty, nowMs);
|
|
753
|
+
continue;
|
|
754
|
+
}
|
|
755
|
+
casualtyDeaths.set(indicatorId, nowMs);
|
|
756
|
+
casualtyQueue.set(indicatorId, casualty);
|
|
757
|
+
queued = true;
|
|
758
|
+
}
|
|
759
|
+
if (queued && casualtyBatchTimer === undefined) {
|
|
760
|
+
casualtyBatchTimer = setTimeout(flushWrunCasualtyBatch, WRUN_CASUALTY_BATCH_MS);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
function flushWrunCasualtyBatch() {
|
|
764
|
+
casualtyBatchTimer = undefined;
|
|
765
|
+
const batch = [...casualtyQueue.values()];
|
|
766
|
+
casualtyQueue.clear();
|
|
767
|
+
ring('wrun-casualty-batch', { indicatorIds: batch.map(({ indicatorId }) => indicatorId) });
|
|
768
|
+
batch.forEach((casualty, index) => {
|
|
769
|
+
if (index === 0) {
|
|
770
|
+
void reseedWrunCasualty(casualty);
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
casualtyStaggers.set(casualty.indicatorId, setTimeout(() => {
|
|
774
|
+
casualtyStaggers.delete(casualty.indicatorId);
|
|
775
|
+
void reseedWrunCasualty(casualty);
|
|
776
|
+
}, index * WRUN_CASUALTY_STAGGER_MS));
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
async function reseedWrunCasualty(casualty) {
|
|
780
|
+
const { indicatorId } = casualty;
|
|
781
|
+
if (!hasWrunOverlayDriver(indicatorId))
|
|
782
|
+
return;
|
|
783
|
+
const chartIndex = getWrunOverlayLiveContext(indicatorId)?.chartIndex ?? casualty.chartIndex;
|
|
784
|
+
try {
|
|
785
|
+
// The run util reads the executor's ports: they load beside it (chart.loadExecutorPorts).
|
|
786
|
+
const [{ reseedWrunOverlayFromBuffers }] = await Promise.all([
|
|
787
|
+
import('./wrun-overlay-run.util.js'),
|
|
788
|
+
wrunChartHostEnv().chart.loadExecutorPorts(),
|
|
789
|
+
]);
|
|
790
|
+
const result = await reseedWrunOverlayFromBuffers(indicatorId, 'session-lost');
|
|
791
|
+
ring('wrun-casualty-reseed', { chartIndex, indicatorId, result });
|
|
792
|
+
if (result !== 'skipped' || !hasWrunOverlayDriver(indicatorId))
|
|
793
|
+
return;
|
|
794
|
+
// The buffers could not reopen the session: the full-run driver rebuilds
|
|
795
|
+
// it over the current window, unless a hold says nothing may run now.
|
|
796
|
+
if (chartIndex !== undefined && (await wrunOverlayHold(chartIndex, indicatorId, 'live-rebuild')) !== null)
|
|
797
|
+
return;
|
|
798
|
+
void rerunWrunOverlayForChartWave(indicatorId, { reason: 'live-rebuild' })?.catch(() => undefined);
|
|
799
|
+
}
|
|
800
|
+
catch (error) {
|
|
801
|
+
// The reseed died with the worker again: a second death inside the window,
|
|
802
|
+
// reported with that death's own record (who held the sandbox this time).
|
|
803
|
+
if (isWrunWorkerPoisonError(error)) {
|
|
804
|
+
requestWrunCasualtyRebuilds([indicatorId], error.death);
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
console.warn(`[wrun] casualty reseed failed for '${indicatorId}' (keeping the last rendered result):`, error);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function parkWrunCasualty(casualty, deathAt) {
|
|
811
|
+
const { indicatorId, chartIndex, death } = casualty;
|
|
812
|
+
// A driver without a live session is what the heal ladder looks after; the
|
|
813
|
+
// suspend also stops the tick lane from reseeding on every frame.
|
|
814
|
+
suspendWrunOverlayLiveSession(indicatorId);
|
|
815
|
+
// The suspend ran the teardown hooks (this module's included): the window
|
|
816
|
+
// keeps counting from this death.
|
|
817
|
+
casualtyDeaths.set(indicatorId, deathAt);
|
|
818
|
+
if (chartIndex !== undefined)
|
|
819
|
+
casualtyCharts.set(indicatorId, chartIndex);
|
|
820
|
+
ring('wrun-casualty-parked', { chartIndex, indicatorId, death });
|
|
821
|
+
if (chartIndex === undefined)
|
|
822
|
+
return;
|
|
823
|
+
// The run deadline's sentence and code (runtime-diagnostics WRUN_RUN_TIMEOUT):
|
|
824
|
+
// the retryable data chip, carrying this death's record and, once the names
|
|
825
|
+
// resolve, the refusal seed that words it for a bystander.
|
|
826
|
+
const deadline = new WrunWorkerPoisonError('timeout', [], death);
|
|
827
|
+
deadline.message = `WRUN run parked timed out after ${WRUN_CASUALTY_PARK_TIMEOUT_MS}ms`;
|
|
828
|
+
// The run util reads the executor's ports: they load beside it (chart.loadExecutorPorts, the ignored third slot).
|
|
829
|
+
void Promise.all([
|
|
830
|
+
import('./wrun-overlay-run.util.js'),
|
|
831
|
+
wrunChartHostEnv().chart.loadTitanCharts(),
|
|
832
|
+
wrunChartHostEnv().chart.loadExecutorPorts(),
|
|
833
|
+
])
|
|
834
|
+
.then(([{ surfaceWrunRunFailureOnLegend }, { getTCGroup }]) => {
|
|
835
|
+
const seed = wrunCasualtyRefusalSeed(casualty, getTCGroup());
|
|
836
|
+
if (seed !== undefined)
|
|
837
|
+
attachWrunRefusal(deadline, seed);
|
|
838
|
+
return surfaceWrunRunFailureOnLegend(chartIndex, indicatorId, deadline);
|
|
839
|
+
})
|
|
840
|
+
.catch((error) => {
|
|
841
|
+
console.warn(`[wrun] parking chip failed for '${indicatorId}':`, error);
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
/** The name an overlay shows on the first of `charts` that mounts it: the
|
|
845
|
+
* titan meta's name, then its settings title (the chart store's display-name
|
|
846
|
+
* rule); '' when none does. */
|
|
847
|
+
function mountedOverlayName(charts, indicatorId) {
|
|
848
|
+
for (const tc of charts) {
|
|
849
|
+
const metas = tc?.metadata;
|
|
850
|
+
if (!Array.isArray(metas))
|
|
851
|
+
continue;
|
|
852
|
+
const meta = metas.find((candidate) => candidate?.id === indicatorId);
|
|
853
|
+
if (!meta)
|
|
854
|
+
continue;
|
|
855
|
+
const name = typeof meta.name === 'string' ? meta.name.trim() : '';
|
|
856
|
+
const title = typeof meta.settings?.title === 'string' ? meta.settings.title.trim() : '';
|
|
857
|
+
if (name || title)
|
|
858
|
+
return name || title;
|
|
859
|
+
}
|
|
860
|
+
return '';
|
|
861
|
+
}
|
|
862
|
+
/** The package id a quarantine key names (`wrunHostQuarantineKey`: the
|
|
863
|
+
* metadata id, then `@` and the wasm digest when the sheet pins one). */
|
|
864
|
+
function quarantinedPackageId(quarantineKey) {
|
|
865
|
+
const at = quarantineKey.lastIndexOf('@');
|
|
866
|
+
return at > 0 ? quarantineKey.slice(0, at) : quarantineKey;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* The refusal seed a parked casualty's chip words its death with (the
|
|
870
|
+
* `not-reached` variants): `held` when a run timed out under a holder that can
|
|
871
|
+
* be named (its live session's overlay by its name on any mounted chart, a
|
|
872
|
+
* session key being the overlay id, else its package id from the quarantine
|
|
873
|
+
* key), with the run budget it used up (counted from dispatch: the words say
|
|
874
|
+
* the holder's run timed out, never that it executed that long); `ended` for a
|
|
875
|
+
* worker error or a holder nobody can name. Undefined when the casualty held
|
|
876
|
+
* the sandbox itself: its own run's deadline words stand. The casualty's own
|
|
877
|
+
* name is resolved the same way; the record falls back to the overlay's
|
|
878
|
+
* refusal context when it resolves to nothing.
|
|
879
|
+
*/
|
|
880
|
+
function wrunCasualtyRefusalSeed(casualty, charts) {
|
|
881
|
+
const { indicatorId, chartIndex, death } = casualty;
|
|
882
|
+
if (death.sessionKey === indicatorId)
|
|
883
|
+
return undefined;
|
|
884
|
+
const own = mountedOverlayName(chartIndex === undefined ? charts : [charts[chartIndex], ...charts], indicatorId);
|
|
885
|
+
const name = own ? { name: own } : {};
|
|
886
|
+
if (death.kind === 'timeout' && death.heldMs !== undefined) {
|
|
887
|
+
const holder = (death.sessionKey !== undefined ? mountedOverlayName(charts, death.sessionKey) : '') ||
|
|
888
|
+
(death.quarantineKey !== undefined ? quarantinedPackageId(death.quarantineKey) : '');
|
|
889
|
+
if (holder) {
|
|
890
|
+
return {
|
|
891
|
+
cls: 'not-reached',
|
|
892
|
+
variant: 'held',
|
|
893
|
+
params: { holder, seconds: Math.round(death.heldMs / 1000), ...name },
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
return { cls: 'not-reached', variant: 'ended', params: { ...name } };
|
|
898
|
+
}
|
|
899
|
+
// ---------------------------------------------------------------------------
|
|
900
|
+
// Teardown, registrations, test seam
|
|
901
|
+
// ---------------------------------------------------------------------------
|
|
902
|
+
/** Everything this module holds for one overlay goes with it (data-loading
|
|
903
|
+
* rule 3). A live-session suspend runs the same hooks: the ladders restart
|
|
904
|
+
* clean after a pause or a parking. */
|
|
905
|
+
function dropWrunRecoveryState(indicatorId) {
|
|
906
|
+
resetWrunOverlayHealLadder(indicatorId);
|
|
907
|
+
healTails.delete(indicatorId);
|
|
908
|
+
retireWrunSourceRecovery(indicatorId, 'teardown');
|
|
909
|
+
forgetWrunGatePlaneReader(indicatorId);
|
|
910
|
+
settledRuns.delete(indicatorId);
|
|
911
|
+
casualtyDeaths.delete(indicatorId);
|
|
912
|
+
casualtyCharts.delete(indicatorId);
|
|
913
|
+
casualtyQueue.delete(indicatorId);
|
|
914
|
+
const stagger = casualtyStaggers.get(indicatorId);
|
|
915
|
+
if (stagger !== undefined)
|
|
916
|
+
clearTimeout(stagger);
|
|
917
|
+
casualtyStaggers.delete(indicatorId);
|
|
918
|
+
}
|
|
919
|
+
// Registered at import like the live intake and the tick lane. Specs that mock
|
|
920
|
+
// the drivers util partially have no hook registry (reading a missing export of
|
|
921
|
+
// a mocked module throws), so the registration is skipped there.
|
|
922
|
+
try {
|
|
923
|
+
onWrunOverlayLiveTeardown(dropWrunRecoveryState);
|
|
924
|
+
}
|
|
925
|
+
catch {
|
|
926
|
+
// partial module mock (specs)
|
|
927
|
+
}
|
|
928
|
+
try {
|
|
929
|
+
onWrunOverlayRunSettled(noteWrunRunSettled);
|
|
930
|
+
}
|
|
931
|
+
catch {
|
|
932
|
+
// partial module mock (specs)
|
|
933
|
+
}
|
|
934
|
+
// The grace's reruns enter here: the boot-side leaf holds no static import of this module.
|
|
935
|
+
try {
|
|
936
|
+
bindWrunTransientRerunAdmission(admitWrunTransientRerun);
|
|
937
|
+
}
|
|
938
|
+
catch {
|
|
939
|
+
// partial module mock (specs)
|
|
940
|
+
}
|
|
941
|
+
// Each edge of a gate plane's session latch runs the overlays that read the plane (the gate session, above).
|
|
942
|
+
try {
|
|
943
|
+
onGateSessionLatchChange(rerunWrunGatePlaneReaders);
|
|
944
|
+
}
|
|
945
|
+
catch {
|
|
946
|
+
// partial module mock (specs)
|
|
947
|
+
}
|
|
948
|
+
export function __resetWrunOverlayRecoveryForTests() {
|
|
949
|
+
healLadders.clear();
|
|
950
|
+
healEpisodes.clear();
|
|
951
|
+
healTails.clear();
|
|
952
|
+
failureClasses.clear();
|
|
953
|
+
quarantineWaits.clear();
|
|
954
|
+
failedLatches.clear();
|
|
955
|
+
for (const recovery of sourceRecoveries.values()) {
|
|
956
|
+
if (recovery.timer !== undefined)
|
|
957
|
+
clearTimeout(recovery.timer);
|
|
958
|
+
}
|
|
959
|
+
sourceRecoveries.clear();
|
|
960
|
+
settledRuns.clear();
|
|
961
|
+
casualtyDeaths.clear();
|
|
962
|
+
casualtyCharts.clear();
|
|
963
|
+
casualtyQueue.clear();
|
|
964
|
+
for (const timer of casualtyStaggers.values())
|
|
965
|
+
clearTimeout(timer);
|
|
966
|
+
casualtyStaggers.clear();
|
|
967
|
+
if (casualtyBatchTimer !== undefined)
|
|
968
|
+
clearTimeout(casualtyBatchTimer);
|
|
969
|
+
casualtyBatchTimer = undefined;
|
|
970
|
+
__resetWrunGatePlaneReadersForTests();
|
|
971
|
+
}
|