import type { ActionResult, ActionType, DecisionMode, HookEvent, ScanResult } from './types.js'; import type { HookSystem } from '../types/hooks.js'; import { EVENT_NAME } from '../utils/event-catalog.js'; import { type EmittableEvent } from './event-derivation.js'; import type { PositionIdResolver } from '../telemetry/event-builders.js'; import { type PositionIdRegistry } from '../runtime/position-id-registry.js'; /** * The producing scan's ids, threaded onto the signal-detected hook event by the runtime. Absent when * the scan carried none — an external producer that stamps nothing leaves both keys off its events. */ export interface ScanIds { tickId?: string; correlationId?: string; } /** * The same ids under the bus-payload key names, for an action that re-fires a lifecycle event from * the pass it is running in. Both are `undefined` when the run carried none; the event builders * read them through `str()`, so an absent id yields an absent attribute. */ export declare function scanIdPayloadFields(event: HookEvent): Record; /** Discriminator for the three order events the descriptor builder maps to event-log records. */ export type OrderEventName = 'order.placed' | 'order.filled' | 'order.failed'; /** * Pure: the deterministic narrative + safe scalar attributes for an order event, from its `data` * bag. `order.failed` routes the venue error payload (free-text) to `redact`; everything else is a * safe scalar. Returns `null` when the payload carries no asset — `senpi.asset` is a required * attribute and an order event without one carries nothing queryable, so it is dropped rather than * emitted with a placeholder. Live sites always pass a real asset; * this is a defensive-only branch. Exported for unit-testing the emitted event shape without a logger. */ export declare function buildOrderEventDescriptor(type: OrderEventName, data: Record, ids?: ScanIds): EmittableEvent | null; export interface ActionEventContext { hookSystem: HookSystem; actionName: string; actionType: ActionType; decisionMode: DecisionMode; decisionModel?: string; minConfidence?: number; /** * Read-only (address, dex, asset) → live position.id accessor over the PositionIdRegistry. Lets the * `signal.outcome` events carry `senpi.position.id`, resolved via the PositionIdRegistry. * Absent → the event simply omits the id (best-effort join hint). */ resolvePositionId?: PositionIdResolver; } /** Fields an action supplies to build its {@link ActionEventContext} — the shared shape behind both actions' `eventCtx()`. */ export interface ActionEventContextInputs { hookSystem: HookSystem; actionName: string; actionType: ActionType; decisionMode: DecisionMode; decisionModel?: string; minConfidence?: number; /** PositionIdRegistry, if wired. Absent → events omit `senpi.position.id` (best-effort join hint). */ positionIdRegistry?: PositionIdRegistry; } /** * Shared factory for the per-action event context. Both the open- and close-position actions * derive an identical context (only their own name/type/config/registry differ), so the * construction lives here once rather than being duplicated in each action's `eventCtx()`. */ export declare function buildActionEventContext(inputs: ActionEventContextInputs): ActionEventContext; /** `order.placed` — an order was submitted / is resting. Reads only values already in scope. */ export declare function emitOrderPlaced(_hookSystem: HookSystem, event: HookEvent, _address: string, data: Record): void; /** `order.filled` — a fill was confirmed. */ export declare function emitOrderFilled(_hookSystem: HookSystem, event: HookEvent, _address: string, data: Record): void; /** `order.failed` — the venue rejected the order or the submit threw. */ export declare function emitOrderFailed(_hookSystem: HookSystem, event: HookEvent, _address: string, data: Record): void; /** Fields an action supplies to build its per-pass scan provenance for the action-result event log. */ export interface ActionResultExtras { scanResult?: ScanResult; minConfidence?: number; } /** * First-class event log for one action-result pass: decision.made + per-signal signal.outcome, * derived from the assembled pass payload. The envelope assembly and the array build both run inside * emitEvents' guard, then emit in one synchronous loop, so a throw can't leave a partial pair and * nothing in this function — projection included — can disturb the action path. */ export declare function emitActionResultEvents(ctx: ActionEventContext, event: HookEvent, address: string, result: ActionResult, extras?: ActionResultExtras): void; //# sourceMappingURL=action-events.d.ts.map