framework.approval.MemoryApprovalConfig#
- class framework.approval.MemoryApprovalConfig(enabled)[source]#
Bases:
object
Configuration model for memory operation approval settings.
Immutable dataclass that encapsulates settings related to memory operation approval. Currently supports simple enabled/disabled logic but is designed for extension with more sophisticated approval rules in the future.
The configuration controls whether memory operations (create, update, delete) require human approval before execution. This provides protection for sensitive user data and system memory state.
- Parameters:
enabled (bool) – Whether memory operation approval is required
Examples
Create memory approval configuration:
>>> config = MemoryApprovalConfig(enabled=True) >>> print(f"Memory approval enabled: {config.enabled}")
Create disabled configuration:
>>> config = MemoryApprovalConfig(enabled=False) >>> # Memory operations will not require approval
Note
This is a frozen dataclass - instances cannot be modified after creation. The design allows for future extensions with additional fields.
- enabled: bool#
- classmethod from_dict(data)[source]#
Create configuration instance from flexible input format with validation.
Factory method that creates a MemoryApprovalConfig instance from either a boolean value (for simple enabled/disabled) or a dictionary (for future extensibility). Applies security-first defaults when configuration is ambiguous.
- Supported Input Formats:
bool: Directly sets the enabled flag
dict: Extracts ‘enabled’ field with secure default
- Parameters:
data (Union[bool, dict]) – Configuration data as boolean or dictionary
- Returns:
Validated configuration instance
- Return type:
- Raises:
ValueError – If data is neither bool nor dict, or bool value is invalid
Examples
Create from boolean:
>>> config = MemoryApprovalConfig.from_dict(True) >>> print(f"Enabled: {config.enabled}")
Create from dictionary:
>>> config_dict = {'enabled': False} >>> config = MemoryApprovalConfig.from_dict(config_dict) >>> print(f"Enabled: {config.enabled}")
Create with secure default:
>>> config = MemoryApprovalConfig.from_dict({}) >>> print(f"Default enabled: {config.enabled}") # True
Handle invalid input:
>>> try: ... config = MemoryApprovalConfig.from_dict("invalid") ... except ValueError as e: ... print(f"Invalid input: {e}")
Note
When using dictionary format, missing ‘enabled’ field defaults to True for security. This ensures approval is required unless explicitly disabled.
- __init__(enabled)#