// src/core/actor/IDispatchStrategy.ts

import type { IMessageMeta } from './IMessageMeta';

/** @deprecated Use IMessageMeta instead */
type MessageMeta = IMessageMeta;

/**
 * Pluggable dispatch strategy.
 *
 * Strategies are tried in priority order (lower = higher priority).
 * First strategy that returns true from canHandle() processes the message.
 *
 * Built-in strategies:
 * - SystemDispatchStrategy (priority 0): Handles $* commands
 * - LispDispatchStrategy (priority 10): LISP handlers
 * - TypeScriptDispatchStrategy (priority 20): onFoo handlers
 */
export interface IDispatchStrategy {
  /** Strategy name for debugging and removal */
  readonly name: string;

  /** Priority (lower = checked first) */
  readonly priority: number;

  /**
   * Check if this strategy can handle the command.
   * Called before handle() to enable short-circuit.
   */
  canHandle(command: string): boolean;

  /**
   * Handle the command.
   * Only called if canHandle() returned true.
   */
  handle(command: string, payload: unknown, meta: MessageMeta): Promise<unknown>;
}
