type InitialDispatchContract = InitialDispatchActiveContract | InitialDispatchScheduleContract;
Contract for lazy per-signal state initialization.
Passed as the first argument to the initialData factory of new State({ name, initialData })
when the factory form is used: the factory runs on every state access for the signal
that has no persisted value yet, and this payload carries the full resolved context of
that moment — so the initial state can be DERIVED from the live signal instead of being
a static constant.
Discriminated union on type: "active" carries the pending IPublicSignalRow of an
open position, "schedule" carries the IScheduledSignalRow of a resting entry — use
payload.type === "active" for type-safe access to the variant-specific signal shape.
Typical use: seed per-trade metrics from the actual entry — e.g. start peakPercent
from the current unrealized PnL, anchor thresholds to signal.priceOpen / TP / SL
distances, or branch the defaults for a resting entry versus an open position.
The payload is assembled by the State facade right after the active signal is resolved
from the async_hooks execution context: signal is the pending or scheduled row,
currentPrice is the VWAP used for that resolution, and when/timestamp carry the
LOGICAL time of the access (candle time in backtest, wall-clock in live) — the same
timestamp that powers the look-ahead guard, so a factory deriving values from it can
never peek ahead of the tick being processed.
The returned object becomes initialValue: it is what reads yield while nothing was
written (or while the stored record is in the future relative to when), and what the
setState dispatch updater receives as prev on the first update. A fresh payload is
built per access, so the factory result is never shared by reference between calls.