@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,630 @@
|
|
|
1
|
+
/** The fingerprints of candle rows (`[ts, open, high, low, close, volume, ...]`), copied and frozen, ascending as
|
|
2
|
+
* given; a row without a finite timestamp is left out. Never shares a row with its input. */
|
|
3
|
+
export function wrunCandleFingerprintsOf(rows) {
|
|
4
|
+
const out = [];
|
|
5
|
+
for (const row of rows) {
|
|
6
|
+
const ts = Number(row?.[0]);
|
|
7
|
+
if (!Number.isFinite(ts))
|
|
8
|
+
continue;
|
|
9
|
+
out.push(Object.freeze([ts, Number(row[1]), Number(row[2]), Number(row[3]), Number(row[4]), Number(row[5])]));
|
|
10
|
+
}
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
/** The index of the first fingerprint stamped at or after `ts` (binary search over ascending stamps). */
|
|
14
|
+
function firstAtOrAfter(rows, ts) {
|
|
15
|
+
let low = 0;
|
|
16
|
+
let high = rows.length;
|
|
17
|
+
while (low < high) {
|
|
18
|
+
const mid = (low + high) >>> 1;
|
|
19
|
+
if (Number(rows[mid][0]) < ts)
|
|
20
|
+
low = mid + 1;
|
|
21
|
+
else
|
|
22
|
+
high = mid;
|
|
23
|
+
}
|
|
24
|
+
return low;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The evidence after a live block evaluated `block` (ascending fingerprints from the block's first bar through its
|
|
28
|
+
* newest): every fingerprint at or after the block's first timestamp replaced by the block, the way the session's
|
|
29
|
+
* outputs merge a block (wrun-live-tick.util `mergeWrunOutputTail`): the kept head is one slice, walked back from the
|
|
30
|
+
* end, so a merge costs the tail, never a walk over the whole evidence. A new array: no reader of the old one sees it
|
|
31
|
+
* change. An empty block keeps the evidence as it is.
|
|
32
|
+
*/
|
|
33
|
+
export function mergeWrunCandleEvidence(evidence, block) {
|
|
34
|
+
const held = evidence ?? [];
|
|
35
|
+
if (block.length === 0)
|
|
36
|
+
return held.slice();
|
|
37
|
+
const fromTs = block[0][0];
|
|
38
|
+
let keep = held.length;
|
|
39
|
+
while (keep > 0 && held[keep - 1][0] >= fromTs)
|
|
40
|
+
keep -= 1;
|
|
41
|
+
const merged = held.slice(0, keep);
|
|
42
|
+
for (const fingerprint of block)
|
|
43
|
+
merged.push(fingerprint);
|
|
44
|
+
return merged;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The evidence after a prefix run landed: `block` (every candle the prefix guest evaluated, ascending: its hidden
|
|
48
|
+
* head, the page, the overlap), then the session's own fingerprints stamped after `throughTs` (the prefix window's
|
|
49
|
+
* last bar), found by one binary search and kept as one slice. A new array.
|
|
50
|
+
*/
|
|
51
|
+
export function prependWrunCandleEvidence(block, evidence, throughTs) {
|
|
52
|
+
const held = evidence ?? [];
|
|
53
|
+
let low = 0;
|
|
54
|
+
let high = held.length;
|
|
55
|
+
while (low < high) {
|
|
56
|
+
const mid = (low + high) >>> 1;
|
|
57
|
+
if (held[mid][0] <= throughTs)
|
|
58
|
+
low = mid + 1;
|
|
59
|
+
else
|
|
60
|
+
high = mid;
|
|
61
|
+
}
|
|
62
|
+
return [...block, ...held.slice(low)];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The retained evidence against the chart's candles as they stand (C4: the whole retained range, never the span the
|
|
66
|
+
* overlap proof reads alone). `chartRows` are the chart's traded candles, ascending (`[ts, open, high, low, close,
|
|
67
|
+
* volume, ...]`). Compared over the evidence's range from the later of its first fingerprint and the chart's first
|
|
68
|
+
* candle up to `guardFromTs` (exclusive: the forming bar and the closed bars the live correction guard still
|
|
69
|
+
* re-reads, which the live tick re-evaluates itself): the two timestamp sets must be equal and every value
|
|
70
|
+
* `Object.is`-equal on open, high, low, close and volume; a landed fingerprint (at or after `landedFromTs`) the chart
|
|
71
|
+
* no longer holds is a difference too, and a hidden-head fingerprint before the chart's first candle is never read
|
|
72
|
+
* (the chart does not hold that bar). Ok, or `candle-revised` with the earliest difference and the words; the
|
|
73
|
+
* evidence is never rewritten with the chart's values.
|
|
74
|
+
*/
|
|
75
|
+
export function proveWrunCandleEvidenceAgainstChart(input) {
|
|
76
|
+
const { evidence, chartRows, landedFromTs, guardFromTs } = input;
|
|
77
|
+
if (evidence === undefined || evidence.length === 0) {
|
|
78
|
+
return fail('candle-revised', null, 'the mounted session kept no candle evidence');
|
|
79
|
+
}
|
|
80
|
+
const chartFirstTs = chartRows.length > 0 ? Number(chartRows[0][0]) : Number.POSITIVE_INFINITY;
|
|
81
|
+
if (chartFirstTs > landedFromTs) {
|
|
82
|
+
return fail('candle-revised', landedFromTs, `the chart no longer holds the landed candle at ${landedFromTs}`);
|
|
83
|
+
}
|
|
84
|
+
const fromTs = Math.max(Number(evidence[0][0]), chartFirstTs);
|
|
85
|
+
let held = firstAtOrAfter(evidence, fromTs);
|
|
86
|
+
let chart = firstAtOrAfter(chartRows, fromTs);
|
|
87
|
+
while (held < evidence.length || chart < chartRows.length) {
|
|
88
|
+
const heldTs = held < evidence.length ? Number(evidence[held][0]) : Number.POSITIVE_INFINITY;
|
|
89
|
+
const chartTs = chart < chartRows.length ? Number(chartRows[chart][0]) : Number.POSITIVE_INFINITY;
|
|
90
|
+
if (Math.min(heldTs, chartTs) >= guardFromTs)
|
|
91
|
+
break;
|
|
92
|
+
if (heldTs !== chartTs) {
|
|
93
|
+
const ts = Math.min(heldTs, chartTs);
|
|
94
|
+
return fail('candle-revised', ts, heldTs < chartTs
|
|
95
|
+
? `candles: the session evaluated a candle at ${ts} the chart no longer holds`
|
|
96
|
+
: `candles: the chart holds a candle at ${ts} the session never evaluated`);
|
|
97
|
+
}
|
|
98
|
+
for (let column = 1; column <= 5; column += 1) {
|
|
99
|
+
const evaluated = Number(evidence[held][column]);
|
|
100
|
+
const current = Number(chartRows[chart][column]);
|
|
101
|
+
if (!Object.is(evaluated, current)) {
|
|
102
|
+
return fail('candle-revised', heldTs, `candles: column ${column} at ${heldTs}: ${show(current)} on the chart, ${show(evaluated)} evaluated`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
held += 1;
|
|
106
|
+
chart += 1;
|
|
107
|
+
}
|
|
108
|
+
return { ok: true };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The candle evidence check alone (the first step of `proveWrunPrefixOverlap`, and the recheck a prefix commit runs
|
|
112
|
+
* against the evidence as it stands then): over the span from `warmupBars` mounted predecessors before the overlap's
|
|
113
|
+
* first timestamp through its last, the prefix run's evaluated candles must equal the mounted evidence, timestamp
|
|
114
|
+
* set and values (`Object.is` on all five). Ok, or `candle-revised` with its earliest timestamp and the words.
|
|
115
|
+
*/
|
|
116
|
+
export function proveWrunCandleEvidence(input) {
|
|
117
|
+
const span = overlapSpanOf(input.overlapTs);
|
|
118
|
+
if (span === null)
|
|
119
|
+
return fail('timestamp-set', null, 'the overlap holds no timestamp');
|
|
120
|
+
const { prefix, mounted } = input.evidence;
|
|
121
|
+
if (mounted === undefined || mounted.length === 0) {
|
|
122
|
+
return fail('candle-revised', null, 'the mounted session kept no candle evidence');
|
|
123
|
+
}
|
|
124
|
+
const warmupBars = Math.max(0, Math.floor(Number(input.evidence.warmupBars) || 0));
|
|
125
|
+
const overlapAt = firstAtOrAfter(mounted, span.from);
|
|
126
|
+
if (overlapAt >= mounted.length || Number(mounted[overlapAt][0]) > span.to) {
|
|
127
|
+
return fail('candle-revised', span.from, 'the mounted evidence holds no candle in the overlap');
|
|
128
|
+
}
|
|
129
|
+
if (overlapAt < warmupBars) {
|
|
130
|
+
return fail('candle-revised', span.from, `the mounted evidence holds ${overlapAt} of the ${warmupBars} evaluated candles before the overlap`);
|
|
131
|
+
}
|
|
132
|
+
const evidenceSpan = { from: Number(mounted[overlapAt - warmupBars][0]), to: span.to };
|
|
133
|
+
const candleTs = (row) => row[0];
|
|
134
|
+
const ours = inSpan(prefix, candleTs, evidenceSpan);
|
|
135
|
+
const theirs = inSpan(mounted, candleTs, evidenceSpan);
|
|
136
|
+
const missing = timestampSetMismatch(ours, theirs);
|
|
137
|
+
if (missing !== null) {
|
|
138
|
+
return fail('candle-revised', missing.ts, `candles: the ${missing.side} side evaluated a candle at ${missing.ts} the ${otherSide(missing.side)} side did not`);
|
|
139
|
+
}
|
|
140
|
+
for (let at = 0; at < ours.length; at += 1) {
|
|
141
|
+
const a = ours[at].item;
|
|
142
|
+
const b = theirs[at].item;
|
|
143
|
+
for (let column = 1; column <= 5; column += 1) {
|
|
144
|
+
if (!Object.is(Number(a[column]), Number(b[column]))) {
|
|
145
|
+
return fail('candle-revised', ours[at].ts, `candles: column ${column} at ${ours[at].ts}: ${show(Number(a[column]))} on the prefix side, ${show(Number(b[column]))} on the mounted side`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { ok: true };
|
|
150
|
+
}
|
|
151
|
+
function fail(reason, firstMismatchTs, detail) {
|
|
152
|
+
return { ok: false, reason, firstMismatchTs, detail };
|
|
153
|
+
}
|
|
154
|
+
/** -0 prints as itself: Object.is tells it from 0, so the detail must too. */
|
|
155
|
+
function show(value) {
|
|
156
|
+
if (Object.is(value, -0))
|
|
157
|
+
return '-0';
|
|
158
|
+
if (typeof value === 'string')
|
|
159
|
+
return JSON.stringify(value);
|
|
160
|
+
return String(value);
|
|
161
|
+
}
|
|
162
|
+
function overlapSpanOf(overlapTs) {
|
|
163
|
+
let from = Number.POSITIVE_INFINITY;
|
|
164
|
+
let to = Number.NEGATIVE_INFINITY;
|
|
165
|
+
for (const ts of overlapTs) {
|
|
166
|
+
if (!Number.isFinite(ts))
|
|
167
|
+
continue;
|
|
168
|
+
if (ts < from)
|
|
169
|
+
from = ts;
|
|
170
|
+
if (ts > to)
|
|
171
|
+
to = ts;
|
|
172
|
+
}
|
|
173
|
+
return from <= to ? { from, to } : null;
|
|
174
|
+
}
|
|
175
|
+
/** The entries inside the span, ascending by timestamp (stable for equal ones; already-sorted input is not re-sorted). */
|
|
176
|
+
function inSpan(items, tsOf, span) {
|
|
177
|
+
const picked = [];
|
|
178
|
+
if (!items)
|
|
179
|
+
return picked;
|
|
180
|
+
let sorted = true;
|
|
181
|
+
for (const item of items) {
|
|
182
|
+
const ts = item === null || item === undefined ? undefined : tsOf(item);
|
|
183
|
+
// Written so a NaN timestamp falls outside every span.
|
|
184
|
+
if (typeof ts !== 'number' || !(ts >= span.from && ts <= span.to))
|
|
185
|
+
continue;
|
|
186
|
+
if (picked.length > 0 && ts < picked[picked.length - 1].ts)
|
|
187
|
+
sorted = false;
|
|
188
|
+
picked.push({ ts, item });
|
|
189
|
+
}
|
|
190
|
+
if (!sorted)
|
|
191
|
+
picked.sort((a, b) => a.ts - b.ts);
|
|
192
|
+
return picked;
|
|
193
|
+
}
|
|
194
|
+
/** The earliest timestamp one side holds that the other lacks (a duplicate counts as its own row), else null. */
|
|
195
|
+
function timestampSetMismatch(prefix, mounted) {
|
|
196
|
+
const length = Math.max(prefix.length, mounted.length);
|
|
197
|
+
for (let at = 0; at < length; at += 1) {
|
|
198
|
+
const a = prefix[at]?.ts;
|
|
199
|
+
const b = mounted[at]?.ts;
|
|
200
|
+
if (a === b)
|
|
201
|
+
continue;
|
|
202
|
+
if (b === undefined || (a !== undefined && a < b))
|
|
203
|
+
return { ts: a, side: 'prefix' };
|
|
204
|
+
return { ts: b, side: 'mounted' };
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
function otherSide(side) {
|
|
209
|
+
return side === 'prefix' ? 'mounted' : 'prefix';
|
|
210
|
+
}
|
|
211
|
+
/** A row read by index: a plain array, or a typed one (the live book lane hands Float64Array rows). */
|
|
212
|
+
function isNumericRow(row) {
|
|
213
|
+
return Array.isArray(row) || (ArrayBuffer.isView(row) && !(row instanceof DataView));
|
|
214
|
+
}
|
|
215
|
+
/** The first column where two numeric rows differ, as plain words; null when they are equal. A typed row and a
|
|
216
|
+
* plain row with the same values are equal: the values are the evidence, not the container. */
|
|
217
|
+
function numericRowDifference(a, b) {
|
|
218
|
+
if (!isNumericRow(a) || !isNumericRow(b))
|
|
219
|
+
return 'a row that is not an array';
|
|
220
|
+
if (a.length !== b.length)
|
|
221
|
+
return `${a.length} values on the prefix side, ${b.length} on the mounted side`;
|
|
222
|
+
for (let column = 0; column < a.length; column += 1) {
|
|
223
|
+
if (!Object.is(a[column], b[column])) {
|
|
224
|
+
return `column ${column}: ${show(a[column])} on the prefix side, ${show(b[column])} on the mounted side`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
/** A lane cell in a detail's words: a nested array (a cell) by its size, any other value as itself. */
|
|
230
|
+
function showLaneCell(value) {
|
|
231
|
+
return isNumericRow(value) ? `a cell of ${value.length}` : show(value);
|
|
232
|
+
}
|
|
233
|
+
/** The first column where two lane rows differ, as plain words; null when they are equal. The same row object is
|
|
234
|
+
* equal; otherwise every column compares with `Object.is`, so a scalar compares by value and a cell (a nested array)
|
|
235
|
+
* by reference: a copy of a cell is another cell, since the overlap's rows are the session's own objects. */
|
|
236
|
+
function laneRowDifference(a, b) {
|
|
237
|
+
if (a === b)
|
|
238
|
+
return null;
|
|
239
|
+
if (!isNumericRow(a) || !isNumericRow(b))
|
|
240
|
+
return 'a row that is not an array';
|
|
241
|
+
if (a.length !== b.length)
|
|
242
|
+
return `${a.length} values on the prefix side, ${b.length} on the mounted side`;
|
|
243
|
+
for (let column = 0; column < a.length; column += 1) {
|
|
244
|
+
if (Object.is(a[column], b[column]))
|
|
245
|
+
continue;
|
|
246
|
+
const cells = isNumericRow(a[column]) && isNumericRow(b[column]) ? ' (cells compare by reference)' : '';
|
|
247
|
+
return `column ${column}: ${showLaneCell(a[column])} on the prefix side, ${showLaneCell(b[column])} on the mounted side${cells}`;
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
/** Lane rows by name, or the duplicated name when a side names one twice. */
|
|
252
|
+
function lanesByName(lanes) {
|
|
253
|
+
const byName = new Map();
|
|
254
|
+
for (const lane of lanes ?? []) {
|
|
255
|
+
if (byName.has(lane.lane))
|
|
256
|
+
return { duplicate: lane.lane };
|
|
257
|
+
byName.set(lane.lane, lane.rows);
|
|
258
|
+
}
|
|
259
|
+
return byName;
|
|
260
|
+
}
|
|
261
|
+
function outputsDifference(a, b) {
|
|
262
|
+
if (a === null || b === null) {
|
|
263
|
+
if (a === b)
|
|
264
|
+
return null;
|
|
265
|
+
return `outputs null on the ${a === null ? 'prefix' : 'mounted'} side only`;
|
|
266
|
+
}
|
|
267
|
+
if (a.length !== b.length)
|
|
268
|
+
return `${a.length} outputs on the prefix side, ${b.length} on the mounted side`;
|
|
269
|
+
for (let index = 0; index < a.length; index += 1) {
|
|
270
|
+
if (!Object.is(a[index], b[index])) {
|
|
271
|
+
return `output ${index}: ${show(a[index])} on the prefix side, ${show(b[index])} on the mounted side`;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
function stringsDifference(a, b) {
|
|
277
|
+
const absentA = a === undefined || a === null;
|
|
278
|
+
const absentB = b === undefined || b === null;
|
|
279
|
+
if (absentA || absentB) {
|
|
280
|
+
if (absentA && absentB)
|
|
281
|
+
return null;
|
|
282
|
+
return `strings absent on the ${absentA ? 'prefix' : 'mounted'} side only`;
|
|
283
|
+
}
|
|
284
|
+
if (a.length !== b.length)
|
|
285
|
+
return `${a.length} strings on the prefix side, ${b.length} on the mounted side`;
|
|
286
|
+
for (let index = 0; index < a.length; index += 1) {
|
|
287
|
+
const left = a[index] ?? null;
|
|
288
|
+
const right = b[index] ?? null;
|
|
289
|
+
if (left !== right)
|
|
290
|
+
return `string ${index}: ${show(left)} on the prefix side, ${show(right)} on the mounted side`;
|
|
291
|
+
}
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
/** Child rows by id, or the duplicated id when a side names one twice. */
|
|
295
|
+
function childrenById(children) {
|
|
296
|
+
const byId = new Map();
|
|
297
|
+
for (const child of children ?? []) {
|
|
298
|
+
if (byId.has(child.childId))
|
|
299
|
+
return { duplicate: child.childId };
|
|
300
|
+
byId.set(child.childId, child.rows);
|
|
301
|
+
}
|
|
302
|
+
return byId;
|
|
303
|
+
}
|
|
304
|
+
const rowTs = (row) => row[0];
|
|
305
|
+
const laneRowTs = (row) => row[0];
|
|
306
|
+
const outputRowTs = (row) => row.ts;
|
|
307
|
+
/** A list compared element by element: an array, or a typed one (a typed list and a plain one with the same values
|
|
308
|
+
* are equal, as rows are). */
|
|
309
|
+
function isList(value) {
|
|
310
|
+
return Array.isArray(value) || (ArrayBuffer.isView(value) && !(value instanceof DataView));
|
|
311
|
+
}
|
|
312
|
+
/** A plain-data record compared key by key: an object literal (or one with no prototype), never a class instance,
|
|
313
|
+
* a Map, a Date or a function, which equal only themselves. */
|
|
314
|
+
function isPlainRecord(value) {
|
|
315
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
316
|
+
return false;
|
|
317
|
+
const prototype = Object.getPrototypeOf(value);
|
|
318
|
+
return prototype === Object.prototype || prototype === null;
|
|
319
|
+
}
|
|
320
|
+
/** A snapshot value in a detail's words. */
|
|
321
|
+
function showSnapshot(value) {
|
|
322
|
+
if (value === undefined)
|
|
323
|
+
return 'absent';
|
|
324
|
+
if (isList(value))
|
|
325
|
+
return `a list of ${value.length}`;
|
|
326
|
+
if (isPlainRecord(value))
|
|
327
|
+
return 'a record';
|
|
328
|
+
if (typeof value === 'object' && value !== null)
|
|
329
|
+
return 'an object that is not plain data';
|
|
330
|
+
return show(value);
|
|
331
|
+
}
|
|
332
|
+
function opened(open, a, b) {
|
|
333
|
+
let partners = open.get(a);
|
|
334
|
+
if (partners?.has(b))
|
|
335
|
+
return true;
|
|
336
|
+
if (partners === undefined) {
|
|
337
|
+
partners = new Set();
|
|
338
|
+
open.set(a, partners);
|
|
339
|
+
}
|
|
340
|
+
partners.add(b);
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
/** Where two snapshot values first differ, as `<path>: <what>`, or null when they are structurally equal (the module
|
|
344
|
+
* note's plain-data rules). Keys compare in sorted order, so the answer never depends on key insertion order. */
|
|
345
|
+
function snapshotDifference(a, b, path, open) {
|
|
346
|
+
if (Object.is(a, b))
|
|
347
|
+
return null;
|
|
348
|
+
const differs = () => `${path}: ${showSnapshot(a)} on the prefix side, ${showSnapshot(b)} on the mounted side`;
|
|
349
|
+
if (isList(a) && isList(b)) {
|
|
350
|
+
if (a.length !== b.length)
|
|
351
|
+
return `${path}: ${a.length} entries on the prefix side, ${b.length} on the mounted side`;
|
|
352
|
+
if (opened(open, a, b))
|
|
353
|
+
return null;
|
|
354
|
+
for (let at = 0; at < a.length; at += 1) {
|
|
355
|
+
const difference = snapshotDifference(a[at], b[at], `${path}[${at}]`, open);
|
|
356
|
+
if (difference !== null)
|
|
357
|
+
return difference;
|
|
358
|
+
}
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
if (isPlainRecord(a) && isPlainRecord(b)) {
|
|
362
|
+
if (opened(open, a, b))
|
|
363
|
+
return null;
|
|
364
|
+
const keys = new Set();
|
|
365
|
+
for (const record of [a, b]) {
|
|
366
|
+
for (const key of Object.keys(record))
|
|
367
|
+
if (record[key] !== undefined)
|
|
368
|
+
keys.add(key);
|
|
369
|
+
}
|
|
370
|
+
for (const key of [...keys].sort()) {
|
|
371
|
+
const difference = snapshotDifference(a[key], b[key], `${path}.${key}`, open);
|
|
372
|
+
if (difference !== null)
|
|
373
|
+
return difference;
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
return differs();
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Whether the prefix run's evidence equals the mounted evidence over the overlap: ok, or the first mismatch with its
|
|
381
|
+
* kind, its earliest timestamp and a plain-words detail. Validation only; the roster admits (see the module note).
|
|
382
|
+
*/
|
|
383
|
+
export function proveWrunPrefixOverlap(input) {
|
|
384
|
+
const span = overlapSpanOf(input.overlapTs);
|
|
385
|
+
if (span === null)
|
|
386
|
+
return fail('timestamp-set', null, 'the overlap holds no timestamp');
|
|
387
|
+
if (input.candleEvidence !== undefined) {
|
|
388
|
+
const candles = proveWrunCandleEvidence({ overlapTs: input.overlapTs, evidence: input.candleEvidence });
|
|
389
|
+
if (!candles.ok)
|
|
390
|
+
return candles;
|
|
391
|
+
}
|
|
392
|
+
const { prefix, mounted } = input;
|
|
393
|
+
const prefixChildren = childrenById(prefix.children);
|
|
394
|
+
if (!(prefixChildren instanceof Map)) {
|
|
395
|
+
return fail('child', null, `child ${prefixChildren.duplicate} named twice on the prefix side`);
|
|
396
|
+
}
|
|
397
|
+
const mountedChildren = childrenById(mounted.children);
|
|
398
|
+
if (!(mountedChildren instanceof Map)) {
|
|
399
|
+
return fail('child', null, `child ${mountedChildren.duplicate} named twice on the mounted side`);
|
|
400
|
+
}
|
|
401
|
+
// Children compare in id order, so the answer never depends on the order a caller listed them.
|
|
402
|
+
const childIds = [...new Set([...prefixChildren.keys(), ...mountedChildren.keys()])].sort();
|
|
403
|
+
const prefixLanes = lanesByName(prefix.lanes);
|
|
404
|
+
if (!(prefixLanes instanceof Map)) {
|
|
405
|
+
return fail('lane', null, `lane ${prefixLanes.duplicate} named twice on the prefix side`);
|
|
406
|
+
}
|
|
407
|
+
const mountedLanes = lanesByName(mounted.lanes);
|
|
408
|
+
if (!(mountedLanes instanceof Map)) {
|
|
409
|
+
return fail('lane', null, `lane ${mountedLanes.duplicate} named twice on the mounted side`);
|
|
410
|
+
}
|
|
411
|
+
// Lanes compare in name order too.
|
|
412
|
+
const laneNames = [...new Set([...prefixLanes.keys(), ...mountedLanes.keys()])].sort();
|
|
413
|
+
const lanes = laneNames.map((name) => ({
|
|
414
|
+
label: `lane ${name}`,
|
|
415
|
+
prefix: inSpan(prefixLanes.get(name), laneRowTs, span),
|
|
416
|
+
mounted: inSpan(mountedLanes.get(name), laneRowTs, span),
|
|
417
|
+
}));
|
|
418
|
+
const inputs = [
|
|
419
|
+
{
|
|
420
|
+
label: 'candles',
|
|
421
|
+
reason: 'candle',
|
|
422
|
+
prefix: inSpan(prefix.candles, rowTs, span),
|
|
423
|
+
mounted: inSpan(mounted.candles, rowTs, span),
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
label: 'book',
|
|
427
|
+
reason: 'book',
|
|
428
|
+
prefix: inSpan(prefix.book, rowTs, span),
|
|
429
|
+
mounted: inSpan(mounted.book, rowTs, span),
|
|
430
|
+
},
|
|
431
|
+
];
|
|
432
|
+
const rows = { prefix: inSpan(prefix.rows, outputRowTs, span), mounted: inSpan(mounted.rows, outputRowTs, span) };
|
|
433
|
+
const children = childIds.map((childId) => ({
|
|
434
|
+
label: `child ${childId}`,
|
|
435
|
+
reason: 'child',
|
|
436
|
+
prefix: inSpan(prefixChildren.get(childId), rowTs, span),
|
|
437
|
+
mounted: inSpan(mountedChildren.get(childId), rowTs, span),
|
|
438
|
+
}));
|
|
439
|
+
// 1. The same timestamp set on both sides: candles, book, each lane (a lane's own reason), rows, then each child.
|
|
440
|
+
const timestampLanes = [
|
|
441
|
+
...inputs.map(({ label, prefix: ours, mounted: theirs }) => ({ label, prefix: ours, mounted: theirs })),
|
|
442
|
+
...lanes.map((lane) => ({ ...lane, reason: 'lane' })),
|
|
443
|
+
{ label: 'rows', ...rows },
|
|
444
|
+
...children.map(({ label, prefix: ours, mounted: theirs }) => ({ label, prefix: ours, mounted: theirs })),
|
|
445
|
+
];
|
|
446
|
+
for (const lane of timestampLanes) {
|
|
447
|
+
const mismatch = timestampSetMismatch(lane.prefix, lane.mounted);
|
|
448
|
+
if (mismatch !== null) {
|
|
449
|
+
const lacking = otherSide(mismatch.side);
|
|
450
|
+
return fail(lane.reason ?? 'timestamp-set', mismatch.ts, `${lane.label}: the ${mismatch.side} side has a row at ${mismatch.ts} the ${lacking} side lacks`);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// 2. Inputs, value by value (a different input explains a different output, so it reports first).
|
|
454
|
+
const laneMismatch = (lane) => {
|
|
455
|
+
for (let at = 0; at < lane.prefix.length; at += 1) {
|
|
456
|
+
const difference = numericRowDifference(lane.prefix[at].item, lane.mounted[at].item);
|
|
457
|
+
if (difference !== null)
|
|
458
|
+
return fail(lane.reason, lane.prefix[at].ts, `${lane.label}: ${difference}`);
|
|
459
|
+
}
|
|
460
|
+
return null;
|
|
461
|
+
};
|
|
462
|
+
for (const lane of inputs) {
|
|
463
|
+
const mismatch = laneMismatch(lane);
|
|
464
|
+
if (mismatch !== null)
|
|
465
|
+
return mismatch;
|
|
466
|
+
}
|
|
467
|
+
for (const lane of lanes) {
|
|
468
|
+
for (let at = 0; at < lane.prefix.length; at += 1) {
|
|
469
|
+
const difference = laneRowDifference(lane.prefix[at].item, lane.mounted[at].item);
|
|
470
|
+
if (difference !== null)
|
|
471
|
+
return fail('lane', lane.prefix[at].ts, `${lane.label}: ${difference}`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
// 3. Outputs, row by row: the outputs, then the strings.
|
|
475
|
+
for (let at = 0; at < rows.prefix.length; at += 1) {
|
|
476
|
+
const ts = rows.prefix[at].ts;
|
|
477
|
+
const a = rows.prefix[at].item;
|
|
478
|
+
const b = rows.mounted[at].item;
|
|
479
|
+
const outputs = outputsDifference(a.outputs, b.outputs);
|
|
480
|
+
if (outputs !== null)
|
|
481
|
+
return fail('output', ts, outputs);
|
|
482
|
+
const strings = stringsDifference(a.strings, b.strings);
|
|
483
|
+
if (strings !== null)
|
|
484
|
+
return fail('string', ts, strings);
|
|
485
|
+
}
|
|
486
|
+
// 4. Children, value by value.
|
|
487
|
+
for (const lane of children) {
|
|
488
|
+
const mismatch = laneMismatch(lane);
|
|
489
|
+
if (mismatch !== null)
|
|
490
|
+
return mismatch;
|
|
491
|
+
}
|
|
492
|
+
// 5. The handle snapshot, whole: the landing replaces the mounted set with the prefix run's.
|
|
493
|
+
const handles = snapshotDifference(prefix.handles, mounted.handles, 'handles', new Map());
|
|
494
|
+
if (handles !== null)
|
|
495
|
+
return fail('handles', null, handles);
|
|
496
|
+
return { ok: true };
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Whether a mismatch refuses the module (the prefix latch: every later page of the overlay's build runs whole) rather
|
|
500
|
+
* than the data: every kind but `candle-revised` (a candle the session's rows rest on was revised) and `lane` (the
|
|
501
|
+
* lanes the overlap ran on are not the session's), which hand the page to a full run and leave the session a
|
|
502
|
+
* candidate. A caller still refuses to latch when the session's mounted rows over the overlap may rest on inputs its
|
|
503
|
+
* buffers no longer hold (wrun-prefix-lanes.util `wrunPrefixOverlapUnproven`): then no output mismatch is the module's.
|
|
504
|
+
*/
|
|
505
|
+
export function wrunPrefixMismatchLatches(reason) {
|
|
506
|
+
return reason !== 'candle-revised' && reason !== 'lane';
|
|
507
|
+
}
|
|
508
|
+
/** The last finite value a column holds over `rows` (NaN when none, or no column): a guide's constant, the rule the
|
|
509
|
+
* run result builds its `value` with (wrun-run-result `role: "guide"`). */
|
|
510
|
+
export function wrunLastFiniteOutput(rows, index) {
|
|
511
|
+
if (index === undefined)
|
|
512
|
+
return Number.NaN;
|
|
513
|
+
for (let at = rows.length - 1; at >= 0; at -= 1) {
|
|
514
|
+
const value = rows[at].outputs?.[index];
|
|
515
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
516
|
+
return value;
|
|
517
|
+
}
|
|
518
|
+
return Number.NaN;
|
|
519
|
+
}
|
|
520
|
+
/** Every last-row style binding a sheet declares, in sheet order (the outputs', then the ranges'). A price-tag flag
|
|
521
|
+
* counts only under `price_display: "per_output"`, the one sheet where the run result reads it. */
|
|
522
|
+
export function wrunPrefixStyleBindingsOf(sheet) {
|
|
523
|
+
const indexOf = new Map();
|
|
524
|
+
for (const output of sheet.outputs ?? [])
|
|
525
|
+
indexOf.set(output.name, output.index);
|
|
526
|
+
const flags = sheet.price_display === 'per_output';
|
|
527
|
+
const bindings = [];
|
|
528
|
+
const add = (owner, key, source, kind) => {
|
|
529
|
+
if (typeof source !== 'string')
|
|
530
|
+
return;
|
|
531
|
+
const name = 'output' in owner ? owner.output : `ranges[${owner.range}]`;
|
|
532
|
+
bindings.push({ binding: `${name}.${key}`, index: indexOf.get(source), kind, owner });
|
|
533
|
+
};
|
|
534
|
+
for (const output of sheet.outputs ?? []) {
|
|
535
|
+
add({ output: output.name }, 'stroke_width_by', output.stroke_width_by, 'width');
|
|
536
|
+
if (flags)
|
|
537
|
+
add({ output: output.name }, 'show_price_display_by', output.show_price_display_by, 'flag');
|
|
538
|
+
}
|
|
539
|
+
for (const [at, range] of (sheet.ranges ?? []).entries()) {
|
|
540
|
+
add({ range: at, upper: range.upper }, 'edge_width_by', range.edge_width_by, 'width');
|
|
541
|
+
if (flags)
|
|
542
|
+
add({ range: at, upper: range.upper }, 'show_price_display_by', range.show_price_display_by, 'flag');
|
|
543
|
+
}
|
|
544
|
+
return bindings;
|
|
545
|
+
}
|
|
546
|
+
/** The style a binding derives on `rows`: its column on the last ready row (the last row whose outputs are not
|
|
547
|
+
* null), read as the run result reads it (wrun-run-result `runWidth`, `priceDisplay`). */
|
|
548
|
+
export function wrunPrefixDerivedStyleOf(rows, binding) {
|
|
549
|
+
if (binding.index === undefined)
|
|
550
|
+
return null;
|
|
551
|
+
for (let at = rows.length - 1; at >= 0; at -= 1) {
|
|
552
|
+
const outputs = rows[at].outputs;
|
|
553
|
+
if (outputs === null)
|
|
554
|
+
continue;
|
|
555
|
+
const value = outputs[binding.index];
|
|
556
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
557
|
+
return null;
|
|
558
|
+
if (binding.kind === 'flag')
|
|
559
|
+
return value !== 0;
|
|
560
|
+
return value >= 0 ? value : null;
|
|
561
|
+
}
|
|
562
|
+
return null;
|
|
563
|
+
}
|
|
564
|
+
/** The family a plot field's detail names it under, by its proof. */
|
|
565
|
+
const PLOT_FIELD_FAMILIES = {
|
|
566
|
+
styles: 'styles',
|
|
567
|
+
'sparse-mount': 'sparse',
|
|
568
|
+
'range-fields': 'ranges',
|
|
569
|
+
};
|
|
570
|
+
/** A snapshot value in a detail's words. */
|
|
571
|
+
function showValue(value) {
|
|
572
|
+
return value === undefined ? 'absent' : show(value);
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* The guide, style and plot-field snapshots of a landing (the module note): ok, or the first mismatch, the guides,
|
|
576
|
+
* then the styles derived on the rows, then the plot fields, each in name order (`guides-incoherent` before `guides`
|
|
577
|
+
* on one guide; a plot field by its key, then its field), no timestamp (a run-level value).
|
|
578
|
+
*/
|
|
579
|
+
export function proveWrunPrefixRunSnapshots(input) {
|
|
580
|
+
const compareText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
581
|
+
const byName = (entries, nameOf) => [...entries].sort((a, b) => compareText(nameOf(a), nameOf(b)));
|
|
582
|
+
for (const guide of byName(input.guides, (entry) => entry.output)) {
|
|
583
|
+
if (!Object.is(guide.mounted, guide.session)) {
|
|
584
|
+
return fail('guides-incoherent', null, `guides.${guide.output}: ${showValue(guide.mounted)} on the mount, ${show(guide.session)} on the session rows`);
|
|
585
|
+
}
|
|
586
|
+
if (!Object.is(guide.prefix, guide.mounted)) {
|
|
587
|
+
return fail('guides', null, `guides.${guide.output}: ${show(guide.prefix)} on the prefix side, ${showValue(guide.mounted)} on the mounted side`);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
for (const style of byName(input.styles, (entry) => entry.binding)) {
|
|
591
|
+
if (!Object.is(style.prefix, style.session)) {
|
|
592
|
+
return fail('styles', null, `styles.${style.binding}: ${show(style.prefix)} on the prefix side, ${show(style.session)} on the session side`);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
const plots = [...(input.plots ?? [])].sort((a, b) => compareText(a.key, b.key) || compareText(a.field, b.field));
|
|
596
|
+
for (const plot of plots) {
|
|
597
|
+
if (snapshotDifference(plot.payload, plot.mounted, 'field', new Map()) !== null) {
|
|
598
|
+
return fail(plot.proof, null, `${PLOT_FIELD_FAMILIES[plot.proof]}.${plot.key}.${plot.field}: ${showField(plot.payload)} in the payload, ${showField(plot.mounted)} on the mount`);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return { ok: true };
|
|
602
|
+
}
|
|
603
|
+
/** A plot field's value in a detail's words: plain data as JSON (a palette, a style table), a scalar as itself. */
|
|
604
|
+
function showField(value) {
|
|
605
|
+
if (value === undefined)
|
|
606
|
+
return 'absent';
|
|
607
|
+
if (isList(value) || isPlainRecord(value)) {
|
|
608
|
+
try {
|
|
609
|
+
return JSON.stringify(isList(value) ? Array.from(value) : value);
|
|
610
|
+
}
|
|
611
|
+
catch {
|
|
612
|
+
return showSnapshot(value);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return show(value);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* The sparse rule of a landing (the module note): ok with the declarations the payload must carry although the prefix
|
|
619
|
+
* result gave them no value (`carried`: shown and not given, in key order), or `sparse-mount` naming the first
|
|
620
|
+
* declaration (key order) the mount omitted while the prefix result gave it a value.
|
|
621
|
+
*/
|
|
622
|
+
export function proveWrunPrefixSparseMount(declarations) {
|
|
623
|
+
const sorted = [...declarations].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
624
|
+
for (const declaration of sorted) {
|
|
625
|
+
if (!declaration.shown && declaration.given) {
|
|
626
|
+
return fail('sparse-mount', null, `sparse.${declaration.key}: omitted on the mount, given a value by the prefix run`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return { ok: true, carried: sorted.filter((entry) => entry.shown && !entry.given).map((entry) => entry.key) };
|
|
630
|
+
}
|