"""AI-only phase model (no Redis / job queue).""" from __future__ import annotations import pytest from app.config import Settings from app.optimization.ai_phases import ( collect_ai_phase_warnings, collect_ai_phases, ) def test_ai_phases_three_buckets() -> None: phases = collect_ai_phases() assert set(phases) == {"phase1", "phase2", "phase3"} for key in phases: assert phases[key]["name"] assert "live" in phases[key] assert "capabilities" in phases[key] def test_phase3_speculation_warning_when_inspector_path_off( monkeypatch: pytest.MonkeyPatch, ) -> None: monkeypatch.setattr("app.optimization.ai_phases.settings.openai_api_key", "sk-test") monkeypatch.setattr("app.optimization.ai_phases.settings.enable_async_pipeline", True) monkeypatch.setattr("app.optimization.ai_phases.settings.enable_speculative_executor", True) monkeypatch.setattr("app.optimization.ai_phases.settings.notes_only_generation", True) monkeypatch.setattr( "app.optimization.ai_phases.settings.agentic_inspector_when_notes_only", False, ) warnings = collect_ai_phase_warnings() assert any("speculation enabled" in w.lower() for w in warnings) def test_scale_profile_enables_ai_phase3_flags_on_settings() -> None: """SCALE_OPTIMIZATION_PROFILE sets AI Phase 3 env flags (job queue is backend).""" s = Settings( _env_file=None, scale_optimization_profile=True, redis_url="redis://localhost:6379/0", ) assert s.enable_async_pipeline is True assert s.enable_speculative_executor is True assert s.enable_prompt_caching is True assert s.enable_job_queue is True