gunn.config package

Submodules

gunn.config.config module

Core configuration management for gunn.

This module provides the main configuration classes and loading functionality with environment variable support and feature flags.

exception gunn.config.config.ConfigError[ソース]

ベースクラス: Exception

Configuration-related errors.

class gunn.config.config.FeatureFlags(latency_simulation=True, backpressure_management=True, staleness_detection=True, cancellation_tokens=True, telemetry=True, metrics_export=True, structured_logging=True, pii_redaction=True, memory_management=True, log_compaction=True, view_caching=True, authentication=False, authorization=False, rate_limiting=True, distributed_mode=False, gpu_acceleration=False)[ソース]

ベースクラス: object

Feature flags for enabling/disabling functionality.

These can be controlled via the GUNN_FEATURES environment variable as a comma-separated list (e.g., "latency,backpressure,telemetry").

パラメータ:
  • latency_simulation (bool)

  • backpressure_management (bool)

  • staleness_detection (bool)

  • cancellation_tokens (bool)

  • telemetry (bool)

  • metrics_export (bool)

  • structured_logging (bool)

  • pii_redaction (bool)

  • memory_management (bool)

  • log_compaction (bool)

  • view_caching (bool)

  • authentication (bool)

  • authorization (bool)

  • rate_limiting (bool)

  • distributed_mode (bool)

  • gpu_acceleration (bool)

latency_simulation: bool = True
backpressure_management: bool = True
staleness_detection: bool = True
cancellation_tokens: bool = True
telemetry: bool = True
metrics_export: bool = True
structured_logging: bool = True
pii_redaction: bool = True
memory_management: bool = True
log_compaction: bool = True
view_caching: bool = True
authentication: bool = False
authorization: bool = False
rate_limiting: bool = True
distributed_mode: bool = False
gpu_acceleration: bool = False
classmethod from_env(env_var='GUNN_FEATURES')[ソース]

Load feature flags from environment variable.

戻り値の型:

FeatureFlags

パラメータ:

env_var (str)

Args:

env_var: Environment variable name (default: GUNN_FEATURES)

Returns:

FeatureFlags instance with features enabled based on env var

to_dict()[ソース]

Convert to dictionary for metrics export.

戻り値の型:

dict[str, bool]

class gunn.config.config.LoggingConfig(**data)[ソース]

ベースクラス: BaseModel

Logging configuration.

パラメータ:
  • level (Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'])

  • format (Literal['json', 'text'])

  • enable_pii_redaction (bool)

  • log_file (str | None)

  • max_file_size_mb (int)

  • backup_count (int)

level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
format: Literal['json', 'text']
enable_pii_redaction: bool
log_file: str | None
max_file_size_mb: int
backup_count: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gunn.config.config.MetricsConfig(**data)[ソース]

ベースクラス: BaseModel

Metrics configuration.

パラメータ:
  • enabled (bool)

  • port (int)

  • path (str)

  • export_interval_seconds (float)

  • include_feature_flags (bool)

enabled: bool
port: int
path: str
export_interval_seconds: float
include_feature_flags: bool
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gunn.config.config.SecurityConfig(**data)[ソース]

ベースクラス: BaseModel

Security configuration.

パラメータ:
  • enable_auth (bool)

  • auth_token_header (str)

  • rate_limit_per_minute (int)

  • max_request_size_mb (int)

  • allowed_origins (list[str])

enable_auth: bool
auth_token_header: str
rate_limit_per_minute: int
max_request_size_mb: int
allowed_origins: list[str]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gunn.config.config.DatabaseConfig(**data)[ソース]

ベースクラス: BaseModel

Database configuration.

パラメータ:
url: str
pool_size: int
max_overflow: int
pool_timeout: int
echo: bool
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gunn.config.config.Config(**data)[ソース]

ベースクラス: BaseModel

Main configuration class for gunn.

This class combines all configuration sections and provides validation and environment variable loading.

パラメータ:
orchestrator: OrchestratorConfig
features: FeatureFlags
logging: LoggingConfig
metrics: MetricsConfig
security: SecurityConfig
database: DatabaseConfig
environment: Literal['development', 'staging', 'production']
debug: bool
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod validate_orchestrator_config(v)[ソース]

Validate orchestrator configuration.

戻り値の型:

Any

パラメータ:

v (Any)

classmethod validate_features(v)[ソース]

Validate feature flags.

戻り値の型:

Any

パラメータ:

v (Any)

gunn.config.config.load_config_from_file(config_path)[ソース]

Load configuration from YAML file.

戻り値の型:

Config

パラメータ:

config_path (Path)

Args:

config_path: Path to configuration file

Returns:

Loaded configuration

Raises:

ConfigError: If configuration is invalid or file cannot be read

gunn.config.config.load_config_from_env()[ソース]

Load configuration from environment variables.

Environment variables are mapped as follows: - GUNN_ENVIRONMENT: Environment name (development/staging/production) - GUNN_DEBUG: Enable debug mode (true/false) - GUNN_FEATURES: Comma-separated list of enabled features - GUNN_LOG_LEVEL: Logging level - GUNN_LOG_FORMAT: Logging format (json/text) - GUNN_METRICS_PORT: Metrics server port - GUNN_DATABASE_URL: Database connection URL - GUNN_MAX_AGENTS: Maximum number of agents - GUNN_STALENESS_THRESHOLD: Staleness detection threshold - GUNN_BACKPRESSURE_POLICY: Backpressure policy (defer/shed/drop)

戻り値の型:

Config

Returns:

Configuration loaded from environment variables

gunn.config.config.load_config(config_path=None)[ソース]

Load configuration from file and environment variables.

Configuration is loaded in the following order (later sources override earlier): 1. Default values 2. Configuration file (if provided) 3. Environment variables

戻り値の型:

Config

パラメータ:

config_path (Path | None)

Args:

config_path: Optional path to configuration file

Returns:

Merged configuration

gunn.config.config.validate_config(config)[ソース]

Validate configuration for consistency and correctness.

戻り値の型:

None

パラメータ:

config (Config)

Args:

config: Configuration to validate

Raises:

ConfigError: If configuration is invalid

gunn.config.deployment module

Deployment configuration and health checks.

This module provides deployment-specific configuration and health check functionality for production deployments.

class gunn.config.deployment.HealthCheckConfig(**data)[ソース]

ベースクラス: BaseModel

Configuration for health checks.

パラメータ:
  • enabled (bool)

  • endpoint (str)

  • readiness_endpoint (str)

  • liveness_endpoint (str)

  • timeout_seconds (float)

  • check_interval_seconds (float)

  • check_database (bool)

  • check_event_log (bool)

  • check_orchestrator (bool)

  • check_memory_usage (bool)

  • max_memory_usage_percent (float)

  • max_response_time_ms (float)

  • max_queue_depth (int)

enabled: bool
endpoint: str
readiness_endpoint: str
liveness_endpoint: str
timeout_seconds: float
check_interval_seconds: float
check_database: bool
check_event_log: bool
check_orchestrator: bool
check_memory_usage: bool
max_memory_usage_percent: float
max_response_time_ms: float
max_queue_depth: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gunn.config.deployment.HealthStatus(healthy, ready, checks, timestamp, response_time_ms)[ソース]

ベースクラス: object

Health check status.

パラメータ:
healthy: bool
ready: bool
checks: dict[str, Any]
timestamp: float
response_time_ms: float
class gunn.config.deployment.DeploymentConfig(**data)[ソース]

ベースクラス: BaseModel

Deployment-specific configuration.

パラメータ:
service_name: str
service_version: str
instance_id: str | None
host: str
port: int
workers: int
health: HealthCheckConfig
shutdown_timeout_seconds: float
max_memory_mb: int | None
max_cpu_percent: float | None
enable_profiling: bool
profiling_interval_seconds: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gunn.config.deployment.HealthChecker(config)[ソース]

ベースクラス: object

Health check implementation.

パラメータ:

config (HealthCheckConfig)

async check_health()[ソース]

Perform comprehensive health check.

戻り値の型:

HealthStatus

Returns:

Health status with detailed check results

get_last_check()[ソース]

Get the last health check result.

戻り値の型:

HealthStatus | None

class gunn.config.deployment.GracefulShutdownHandler(timeout_seconds=30.0)[ソース]

ベースクラス: object

Handles graceful shutdown of the service.

パラメータ:

timeout_seconds (float)

register_shutdown_task(coro)[ソース]

Register a coroutine to run during shutdown.

戻り値の型:

None

パラメータ:

coro (Coroutine[Any, Any, Any])

async shutdown()[ソース]

Perform graceful shutdown.

戻り値の型:

None

is_shutting_down()[ソース]

Check if shutdown is in progress.

戻り値の型:

bool

async wait_for_shutdown()[ソース]

Wait for shutdown signal.

戻り値の型:

None

gunn.config.environment module

Environment detection and configuration.

This module provides utilities for detecting the current environment and loading environment-specific configurations.

class gunn.config.environment.Environment(*values)[ソース]

ベースクラス: Enum

Supported deployment environments.

DEVELOPMENT = 'development'
STAGING = 'staging'
PRODUCTION = 'production'
TESTING = 'testing'
gunn.config.environment.get_environment()[ソース]

Detect current environment from various sources.

Environment is detected in the following order: 1. GUNN_ENVIRONMENT environment variable 2. NODE_ENV environment variable (for compatibility) 3. Presence of specific files (.env.production, etc.) 4. Default to development

戻り値の型:

Environment

Returns:

Detected environment

gunn.config.environment.get_config_file_path(environment=None)[ソース]

Get the configuration file path for the given environment.

戻り値の型:

Path | None

パラメータ:

environment (Environment | None)

Args:

environment: Environment to get config for (defaults to current)

Returns:

Path to configuration file, or None if not found

gunn.config.environment.is_production()[ソース]

Check if running in production environment.

戻り値の型:

bool

gunn.config.environment.is_development()[ソース]

Check if running in development environment.

戻り値の型:

bool

gunn.config.environment.is_testing()[ソース]

Check if running in testing environment.

戻り値の型:

bool

Module contents

Configuration management for gunn.

This module provides configuration loading, validation, and feature flag management for the multi-agent simulation core.

class gunn.config.Config(**data)[ソース]

ベースクラス: BaseModel

Main configuration class for gunn.

This class combines all configuration sections and provides validation and environment variable loading.

パラメータ:
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod validate_features(v)[ソース]

Validate feature flags.

戻り値の型:

Any

パラメータ:

v (Any)

classmethod validate_orchestrator_config(v)[ソース]

Validate orchestrator configuration.

戻り値の型:

Any

パラメータ:

v (Any)

orchestrator: OrchestratorConfig
features: FeatureFlags
logging: LoggingConfig
metrics: MetricsConfig
security: SecurityConfig
database: DatabaseConfig
environment: Literal['development', 'staging', 'production']
debug: bool
exception gunn.config.ConfigError[ソース]

ベースクラス: Exception

Configuration-related errors.

class gunn.config.DeploymentConfig(**data)[ソース]

ベースクラス: BaseModel

Deployment-specific configuration.

パラメータ:
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

service_name: str
service_version: str
instance_id: str | None
host: str
port: int
workers: int
health: HealthCheckConfig
shutdown_timeout_seconds: float
max_memory_mb: int | None
max_cpu_percent: float | None
enable_profiling: bool
profiling_interval_seconds: float
class gunn.config.Environment(*values)[ソース]

ベースクラス: Enum

Supported deployment environments.

DEVELOPMENT = 'development'
STAGING = 'staging'
PRODUCTION = 'production'
TESTING = 'testing'
class gunn.config.FeatureFlags(latency_simulation=True, backpressure_management=True, staleness_detection=True, cancellation_tokens=True, telemetry=True, metrics_export=True, structured_logging=True, pii_redaction=True, memory_management=True, log_compaction=True, view_caching=True, authentication=False, authorization=False, rate_limiting=True, distributed_mode=False, gpu_acceleration=False)[ソース]

ベースクラス: object

Feature flags for enabling/disabling functionality.

These can be controlled via the GUNN_FEATURES environment variable as a comma-separated list (e.g., "latency,backpressure,telemetry").

パラメータ:
  • latency_simulation (bool)

  • backpressure_management (bool)

  • staleness_detection (bool)

  • cancellation_tokens (bool)

  • telemetry (bool)

  • metrics_export (bool)

  • structured_logging (bool)

  • pii_redaction (bool)

  • memory_management (bool)

  • log_compaction (bool)

  • view_caching (bool)

  • authentication (bool)

  • authorization (bool)

  • rate_limiting (bool)

  • distributed_mode (bool)

  • gpu_acceleration (bool)

authentication: bool = False
authorization: bool = False
backpressure_management: bool = True
cancellation_tokens: bool = True
distributed_mode: bool = False
classmethod from_env(env_var='GUNN_FEATURES')[ソース]

Load feature flags from environment variable.

戻り値の型:

FeatureFlags

パラメータ:

env_var (str)

Args:

env_var: Environment variable name (default: GUNN_FEATURES)

Returns:

FeatureFlags instance with features enabled based on env var

gpu_acceleration: bool = False
latency_simulation: bool = True
log_compaction: bool = True
memory_management: bool = True
metrics_export: bool = True
pii_redaction: bool = True
rate_limiting: bool = True
staleness_detection: bool = True
structured_logging: bool = True
telemetry: bool = True
to_dict()[ソース]

Convert to dictionary for metrics export.

戻り値の型:

dict[str, bool]

view_caching: bool = True
class gunn.config.HealthCheckConfig(**data)[ソース]

ベースクラス: BaseModel

Configuration for health checks.

パラメータ:
  • enabled (bool)

  • endpoint (str)

  • readiness_endpoint (str)

  • liveness_endpoint (str)

  • timeout_seconds (float)

  • check_interval_seconds (float)

  • check_database (bool)

  • check_event_log (bool)

  • check_orchestrator (bool)

  • check_memory_usage (bool)

  • max_memory_usage_percent (float)

  • max_response_time_ms (float)

  • max_queue_depth (int)

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

enabled: bool
endpoint: str
readiness_endpoint: str
liveness_endpoint: str
timeout_seconds: float
check_interval_seconds: float
check_database: bool
check_event_log: bool
check_orchestrator: bool
check_memory_usage: bool
max_memory_usage_percent: float
max_response_time_ms: float
max_queue_depth: int
gunn.config.get_environment()[ソース]

Detect current environment from various sources.

Environment is detected in the following order: 1. GUNN_ENVIRONMENT environment variable 2. NODE_ENV environment variable (for compatibility) 3. Presence of specific files (.env.production, etc.) 4. Default to development

戻り値の型:

Environment

Returns:

Detected environment

gunn.config.load_config(config_path=None)[ソース]

Load configuration from file and environment variables.

Configuration is loaded in the following order (later sources override earlier): 1. Default values 2. Configuration file (if provided) 3. Environment variables

戻り値の型:

Config

パラメータ:

config_path (Path | None)

Args:

config_path: Optional path to configuration file

Returns:

Merged configuration

gunn.config.load_config_from_env()[ソース]

Load configuration from environment variables.

Environment variables are mapped as follows: - GUNN_ENVIRONMENT: Environment name (development/staging/production) - GUNN_DEBUG: Enable debug mode (true/false) - GUNN_FEATURES: Comma-separated list of enabled features - GUNN_LOG_LEVEL: Logging level - GUNN_LOG_FORMAT: Logging format (json/text) - GUNN_METRICS_PORT: Metrics server port - GUNN_DATABASE_URL: Database connection URL - GUNN_MAX_AGENTS: Maximum number of agents - GUNN_STALENESS_THRESHOLD: Staleness detection threshold - GUNN_BACKPRESSURE_POLICY: Backpressure policy (defer/shed/drop)

戻り値の型:

Config

Returns:

Configuration loaded from environment variables

gunn.config.load_config_from_file(config_path)[ソース]

Load configuration from YAML file.

戻り値の型:

Config

パラメータ:

config_path (Path)

Args:

config_path: Path to configuration file

Returns:

Loaded configuration

Raises:

ConfigError: If configuration is invalid or file cannot be read

gunn.config.validate_config(config)[ソース]

Validate configuration for consistency and correctness.

戻り値の型:

None

パラメータ:

config (Config)

Args:

config: Configuration to validate

Raises:

ConfigError: If configuration is invalid