export interface ActorRef { readonly kind: string; readonly id: string; } export interface TransitionCommand { readonly entityId: string; readonly eventId: string; readonly idempotency: import('../durable/types.js').ScopedIdempotency; readonly expectedRevision: number; readonly actor: ActorRef; readonly reason: string; readonly correlationId: string; readonly event: E; readonly payload: P; readonly occurredAt: string; } export interface StateRecord { readonly entityId: string; readonly machineId: string; readonly machineVersion: number; readonly state: S; readonly revision: number; readonly lastEventId: string; readonly updatedAt: string; } export interface AuditEvent { readonly eventId: string; readonly entityId: string; readonly machineId: string; readonly correlationId: string; readonly actor: ActorRef; readonly reason: string; readonly outcome: 'applied' | 'denied'; readonly denialReason?: string; readonly occurredAt: string; readonly fromRevision: number; readonly toRevision: number; } export interface OutboxMessage { readonly topic: string; readonly payload: unknown; } export type TransitionResult = { readonly denied: string; } | { readonly nextState: S; readonly outbox?: readonly OutboxMessage[]; }; export interface MachineDefinition { readonly machineId: string; readonly machineVersion: number; readonly initialState: S; transition(state: S, command: TransitionCommand): TransitionResult; } interface MachineCommitBase { readonly expectedRevision: number; readonly event: AuditEvent; readonly idempotency: import('../durable/types.js').ScopedIdempotency; } export type MachineCommit = (MachineCommitBase & { readonly kind: 'applied'; readonly next: StateRecord; readonly outbox: readonly OutboxMessage[]; }) | (MachineCommitBase & { readonly kind: 'denied'; }); export interface MachineStore { load(machineId: string, entityId: string): Promise | null>; commit(input: MachineCommit): Promise<'committed' | 'duplicate' | 'conflict'>; } export type DispatchResult = { readonly status: 'applied'; readonly record: StateRecord; } | { readonly status: 'duplicate' | 'conflict'; } | { readonly status: 'denied'; readonly reason: string; }; export {};