/** * The event-log half of the real domain events on the bus: `position.*` lifecycle and `dsl.*` * transitions. Unlike the action-origin events (order/decision/outcome), these are first-class facts * already broadcast on the `SenpiEventBus` — so one thin subscriber maps each to a `logger.event`, * reusing the pure builders ({@link buildPositionLifecycle} / {@link buildDslTransition}) * for the field projection rather than re-parsing the payloads. * * Why a subscriber, not at-site: the bus is a synchronous `EventEmitter`, so a handler runs in the * emitter's async context — it inherits the active span (trace_id/span_id auto-stamp) and the * `trackingContext` identity exactly as an at-site emit would. Position events fire inside the signal * flow; `dsl.*` transitions fire inside the monitor tick, which the DSL plugin wraps in a * `trackingContext` so these carry identity too. * * All fields here are safe scalars — these events carry no free-text, so none use the `redact` slot. */ import type { SenpiEventBus } from "../types/event-bus.js"; import type { DslTransitionKind, PositionLifecycleEvent } from "../telemetry/event-builders.js"; import { type EmittableEvent } from "../actions/event-derivation.js"; /** * Map a `position.*` lifecycle record to its event. An `opened` whose `reconciliation_source` is * `externally_detected` is surfaced as `position.reconciled` — a gap-pass position the runtime did * not open — so the two are distinguishable downstream; everything else maps one-to-one. All `info`. */ declare function buildPositionLifecycleEvent(event: PositionLifecycleEvent, payload: unknown, nowMs: number): EmittableEvent | null; /** Map a `dsl.*` transition record to its event. All `info` — failure rides `dsl.closed`'s reason. */ declare function buildDslTransitionEvent(transition: DslTransitionKind, payload: unknown, nowMs: number): EmittableEvent | null; export interface DomainEventSubscriber { /** Unsubscribe every handler. Idempotent. */ dispose(): void; } /** * Subscribe the event log to the `position.*` / `dsl.*` domain events on the bus. Each handler builds * its event through {@link emitEvent}'s guard, so a throwing builder or a telemetry failure can never * propagate back through `bus.emit` into the trading path. Attach only when telemetry is enabled * (per-event assembly on the serial path is dead work otherwise). */ export declare function createDomainEventSubscriber(bus: SenpiEventBus): DomainEventSubscriber; export declare const __test: { buildPositionLifecycleEvent: typeof buildPositionLifecycleEvent; buildDslTransitionEvent: typeof buildDslTransitionEvent; }; export {}; //# sourceMappingURL=domain-events.d.ts.map