ScheduleRunner

class ScheduleRunner(brokerZoneIdFor: (String) -> ZoneId?? = null)

Clock-driven runner for SCHEDULE blocks (#77 Phase 40).

Each registered trigger carries a nextFireMs watermark. tick is called once per ingest from TradingPipeline.ingest(tick) and once per second from a LiveSession timer (live only — for quiet markets); it advances watermarks and emits the action lambda when due.

Backtest determinism: the runner reads time only via the tick argument — the same simulated clock that drives the rest of the engine — so a backtest of a strategy with SCHEDULE AT 09:00 UTC fires the action at the same simulated instant on every run, regardless of wall clock.

Fire model: replay missed occurrences. Every elapsed fire is emitted once with its scheduled event-time. Live's one-second heartbeat and sparse backtest ticks therefore observe the same occurrence count across quiet market gaps.

Constructors

Link copied to clipboard
constructor(brokerZoneIdFor: (String) -> ZoneId?? = null)

Functions

Link copied to clipboard
fun register(strategyId: String, schedule: ScheduleDecl, emit: () -> Unit = {}, emitAt: (Long) -> Boolean? = null, nowMs: Long)

Register every trigger inside schedule under strategyId. nowMs is the engine's current clock at registration time — it seeds the watermark so the first eligible fire is the next one after registration.

Link copied to clipboard
fun tick(nowMs: Long)

Heartbeat. For each registered trigger: Emit every elapsed occurrence in chronological order.

Link copied to clipboard

Total trigger count across all strategies. Test/debug helper.

Link copied to clipboard
fun unregister(strategyId: String)

Drop every trigger attributed to strategyId. Idempotent.