File size: 1,692 Bytes
be9fd4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""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