Foundation.Types.Config (foundation v0.1.0)

Pure data structure for Foundation configuration.

Contains no business logic - just data and Access implementation. All validation and manipulation logic is in separate modules.

This struct defines the complete configuration schema for Foundation, including AI, capture, storage, interface, and development settings.

See @type t for the complete type specification.

Examples

iex> config = Foundation.Types.Config.new()
iex> config.ai.provider
:mock

iex> config = Foundation.Types.Config.new(dev: %{debug_mode: true})
iex> config.dev.debug_mode
true

Summary

Types

AI configuration section

Capture configuration section

Development configuration section

Infrastructure configuration section

Interface configuration section

Storage configuration section

t()

Functions

Fetch a configuration key.

Get and update a configuration key.

Create a new configuration with default values.

Create a new configuration with overrides.

Pop a configuration key.

Types

ai_config()

@type ai_config() :: %{
  provider: :mock | :openai | :anthropic,
  api_key: String.t() | nil,
  model: String.t(),
  analysis: %{
    max_file_size: pos_integer(),
    timeout: pos_integer(),
    cache_ttl: pos_integer()
  },
  planning: %{
    default_strategy: :balanced | :fast | :thorough,
    performance_target: float(),
    sampling_rate: float()
  }
}

AI configuration section

capture_config()

@type capture_config() :: %{
  ring_buffer: %{
    size: pos_integer(),
    max_events: pos_integer(),
    overflow_strategy: :drop_oldest | :drop_newest | :error,
    num_buffers: :schedulers | pos_integer()
  },
  processing: %{
    batch_size: pos_integer(),
    flush_interval: pos_integer(),
    max_queue_size: pos_integer()
  },
  vm_tracing: %{
    enable_spawn_trace: boolean(),
    enable_exit_trace: boolean(),
    enable_message_trace: boolean(),
    trace_children: boolean()
  }
}

Capture configuration section

dev_config()

@type dev_config() :: %{
  debug_mode: boolean(),
  verbose_logging: boolean(),
  performance_monitoring: boolean()
}

Development configuration section

infrastructure_config()

@type infrastructure_config() :: %{
  rate_limiting: %{
    default_rules: %{
      required(atom()) => %{scale: pos_integer(), limit: pos_integer()}
    },
    enabled: boolean(),
    cleanup_interval: pos_integer()
  },
  circuit_breaker: %{
    default_config: %{
      failure_threshold: pos_integer(),
      recovery_time: pos_integer(),
      call_timeout: pos_integer()
    },
    enabled: boolean()
  },
  connection_pool: %{
    default_config: %{
      size: pos_integer(),
      max_overflow: pos_integer(),
      strategy: :lifo | :fifo
    },
    enabled: boolean()
  }
}

Infrastructure configuration section

interface_config()

@type interface_config() :: %{
  query_timeout: pos_integer(),
  max_results: pos_integer(),
  enable_streaming: boolean()
}

Interface configuration section

storage_config()

@type storage_config() :: %{
  hot: %{
    max_events: pos_integer(),
    max_age_seconds: pos_integer(),
    prune_interval: pos_integer()
  },
  warm: %{
    enable: boolean(),
    path: String.t(),
    max_size_mb: pos_integer(),
    compression: :zstd | :gzip | :none
  },
  cold: %{enable: boolean()}
}

Storage configuration section

t()

@type t() :: %Foundation.Types.Config{
  ai: ai_config(),
  capture: capture_config(),
  dev: dev_config(),
  infrastructure: infrastructure_config(),
  interface: interface_config(),
  storage: storage_config()
}

Functions

fetch(config, key)

@spec fetch(t(), atom()) :: {:ok, term()} | :error

Fetch a configuration key.

Implementation of the Access behaviour for configuration structs.

get_and_update(config, key, function)

@spec get_and_update(t(), atom(), (term() -> {term(), term()} | :pop)) ::
  {term(), t()}

Get and update a configuration key.

Implementation of the Access behaviour for configuration structs.

new()

@spec new() :: t()

Create a new configuration with default values.

Examples

iex> config = Foundation.Types.Config.new()
iex> config.ai.provider
:mock

iex> config.capture.ring_buffer.size
1024

new(overrides)

@spec new(keyword()) :: t()

Create a new configuration with overrides.

Performs deep merging of nested configuration maps.

Parameters

  • overrides: Keyword list of configuration overrides

Examples

iex> config = Foundation.Types.Config.new(dev: %{debug_mode: true})
iex> config.dev.debug_mode
true

iex> config = Foundation.Types.Config.new(ai: %{provider: :openai})
iex> config.ai.provider
:openai

pop(config, key)

@spec pop(t(), atom()) :: {term(), t()}

Pop a configuration key.

Implementation of the Access behaviour for configuration structs.