// src/lisp/config.ts
// LISP Configuration - Centralized settings for timeouts, node counts, etc.
//
// All configurable values in one place to avoid hardcoded magic numbers.

/**
 * LISP Configuration interface
 */
export interface ILispConfig {
  // RPC timeouts (ms)
  defaultTimeoutMs: number;      // Default timeout for all RPC calls
  rpcTimeoutMs: number;          // Synonym for defaultTimeoutMs

  // VLM configuration
  nodeCount: number;             // Number of bootstrap nodes to spawn
  atomizeThreshold: number;      // Minimum args to trigger parallelization

  // Stream configuration
  maxSubscriptions: number;      // Maximum active stream subscriptions

  // Debug
  enableTracing: boolean;        // Log evaluation traces
}

/**
 * Default configuration values
 */
export const DEFAULT_LISP_CONFIG: ILispConfig = {
  defaultTimeoutMs: 5000,
  rpcTimeoutMs: 5000,
  nodeCount: 5,
  atomizeThreshold: 2,
  maxSubscriptions: 100,
  enableTracing: false,
};

/**
 * Global configuration instance (mutable for runtime configuration)
 */
let _currentConfig: ILispConfig = { ...DEFAULT_LISP_CONFIG };

/**
 * Get the current LISP configuration
 */
export function getLispConfig(): ILispConfig {
  return { ..._currentConfig };
}

/**
 * Update the LISP configuration (partial update)
 */
export function setLispConfig(config: Partial<ILispConfig>): void {
  _currentConfig = { ..._currentConfig, ...config };
}

/**
 * Reset configuration to defaults
 */
export function resetLispConfig(): void {
  _currentConfig = { ...DEFAULT_LISP_CONFIG };
}
