"""
Atomizer Context Engineering Module

Implements state-of-the-art context engineering for LLM-powered optimization.
Based on the ACE (Agentic Context Engineering) framework.

Components:
- Playbook: Structured knowledge store with helpful/harmful tracking
- Reflector: Analyzes optimization outcomes to extract insights
- SessionState: Context isolation with exposed/isolated separation
- CacheMonitor: KV-cache optimization for cost reduction
- FeedbackLoop: Automated learning from execution
- Compaction: Long-running session context management

Usage:
    from optimization_engine.context import (
        AtomizerPlaybook,
        AtomizerReflector,
        AtomizerSessionState,
        FeedbackLoop,
        CompactionManager
    )

    # Load or create playbook
    playbook = AtomizerPlaybook.load(path)

    # Create feedback loop for learning
    feedback = FeedbackLoop(playbook_path)

    # Process trial results
    feedback.process_trial_result(...)

    # Finalize and commit learning
    feedback.finalize_study(stats)
"""

from .playbook import (
    AtomizerPlaybook,
    PlaybookItem,
    InsightCategory,
    get_playbook,
    save_playbook,
)

from .reflector import (
    AtomizerReflector,
    OptimizationOutcome,
    InsightCandidate,
    ReflectorFactory,
)

from .session_state import (
    AtomizerSessionState,
    ExposedState,
    IsolatedState,
    TaskType,
    get_session,
    set_session,
    clear_session,
)

from .cache_monitor import (
    ContextCacheOptimizer,
    CacheStats,
    ContextSection,
    StablePrefixBuilder,
    get_cache_optimizer,
)

from .feedback_loop import (
    FeedbackLoop,
    FeedbackLoopFactory,
)

from .compaction import (
    CompactionManager,
    ContextEvent,
    EventType,
    ContextBudgetManager,
)

__all__ = [
    # Playbook
    "AtomizerPlaybook",
    "PlaybookItem",
    "InsightCategory",
    "get_playbook",
    "save_playbook",

    # Reflector
    "AtomizerReflector",
    "OptimizationOutcome",
    "InsightCandidate",
    "ReflectorFactory",

    # Session State
    "AtomizerSessionState",
    "ExposedState",
    "IsolatedState",
    "TaskType",
    "get_session",
    "set_session",
    "clear_session",

    # Cache Monitor
    "ContextCacheOptimizer",
    "CacheStats",
    "ContextSection",
    "StablePrefixBuilder",
    "get_cache_optimizer",

    # Feedback Loop
    "FeedbackLoop",
    "FeedbackLoopFactory",

    # Compaction
    "CompactionManager",
    "ContextEvent",
    "EventType",
    "ContextBudgetManager",
]

__version__ = "1.0.0"
