53111dbb95
* auto-claude: subtask-1-1 - Remove validation_strategy backward compatibility shim - Delete apps/backend/validation_strategy.py shim file that re-exported from spec.validation_strategy - Update docstring in spec/validation_strategy.py to show correct import path Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * auto-claude: subtask-1-2 - Remove service_orchestrator shim - Deleted apps/backend/service_orchestrator.py backward compatibility shim file - Updated docstring in services/orchestrator.py to use correct import path (from services.orchestrator import instead of from service_orchestrator import) - Verified no external imports of the shim remain in the codebase - Import from services.orchestrator works correctly Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * auto-claude: subtask-2-1 - Remove Chunk/ChunkStatus aliases from implementation_plan Removed backwards compatibility aliases as part of cleaning up outdated compatibility shims: - Removed ChunkStatus = SubtaskStatus from enums.py - Removed Chunk = Subtask from subtask.py - Removed Chunk/ChunkStatus exports from __init__.py - Updated all test files to use canonical names (Subtask, SubtaskStatus) This completes subtasks 2-1, 2-2, and 2-3 together since the test files depend on all three changes being made atomically. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * auto-claude: subtask-2-4 - Remove deprecated use_orchestrator_review field from GitHub runner models * auto-claude: subtask-3-1 - Update apps/frontend/src/main/index.ts to use platform imports * auto-claude: subtask-3-2 - Update python-detector.ts to use platform imports - Import isWindows from ./platform module - Replace all process.platform === 'win32' checks with isWindows() calls - Remove redundant local isWindows variable declarations * auto-claude: subtask-3-3 - Update apps/frontend/src/main/claude-cli-utils.ts to use platform imports * auto-claude: subtask-3-4 - Update apps/frontend/src/main/config-paths.ts to use platform imports * auto-claude: subtask-3-5 - Update apps/frontend/src/main/memory-service.ts to use platform imports * auto-claude: subtask-4-1 - Update claude-code-handlers.ts to use platform imports Replace all direct process.platform checks with centralized platform abstraction functions from ../platform module: - isWindows() for Windows platform checks - isMacOS() for macOS/Darwin platform checks - isLinux() for Linux platform checks This removes 6 instances of process.platform === '...' comparisons and 1 local isWindows variable assignment, replacing them with the platform abstraction layer for better cross-platform consistency. * auto-claude: subtask-4-2 - Update apps/frontend/src/main/ipc-handlers/mcp-handlers.ts to use platform imports * auto-claude: subtask-4-3 - Update apps/frontend/src/main/ipc-handlers/memory-handlers.ts to use platform imports - Replace process.platform checks with platform module functions - Add getOllamaExecutablePaths(), getOllamaInstallCommand(), and getWhichCommand() to platform/paths.ts - Export new functions from platform/index.ts - Migrate checkOllamaInstalled() to use platform module for path resolution - Migrate getOllamaInstallCommand() to delegate to platform module - Update debug log to use getCurrentOS() instead of process.platform Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * auto-claude: subtask-4-4 - Update apps/frontend/src/main/ipc-handlers/termina * auto-claude: subtask-4-5 - Update apps/frontend/src/main/ipc-handlers/github/ - Replace direct process.platform check with getWhichCommand() from platform abstraction - Import getWhichCommand from ../../platform for cross-platform which/where command * auto-claude: subtask-4-6 - Update apps/frontend/src/main/ipc-handlers/github/utils/subprocess-runner.ts to use platform imports * auto-claude: subtask-5-1 - Update apps/frontend/src/main/agent/agent-process.ts Replace direct process.platform checks with platform abstraction: - Import isWindows from ../platform module - Replace `process.platform !== 'win32'` with `!isWindows()` - Replace `process.platform === 'win32'` with `isWindows()` This ensures consistent platform detection using the centralized platform abstraction layer. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * auto-claude: subtask-5-2 - Update apps/frontend/src/main/agent/agent-queue.ts * auto-claude: subtask-5-3 - Update apps/frontend/src/main/terminal/pty-daemon.ts to use platform imports * auto-claude: subtask-5-4 - Update pty-daemon-client.ts to use platform imports Replace direct process.platform === 'win32' check with isWindows() from the platform abstraction layer for consistent cross-platform handling of socket paths. * auto-claude: subtask-5-5 - Update apps/frontend/src/main/insights/config.ts to use platform imports - Import isWindows() from '../platform' - Replace process.platform === 'win32' checks with isWindows() - Maintains case-insensitive path comparison on Windows * auto-claude: subtask-5-6 - Update apps/frontend/src/main/changelog/version-suggester.ts to use platform imports * auto-claude: subtask-5-7 - Update apps/frontend/src/main/changelog/generator. * fix: Remove unused import and fix test import paths - Remove unused `isWindows` import from memory-handlers.ts - Fix test_service_orchestrator.py to import from services.orchestrator instead of the removed service_orchestrator shim - Fix case sensitivity in path ("Apps" -> "apps") Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Fix test import paths for case sensitivity and removed shims - Fix path case sensitivity: "Apps" -> "apps" in 21 test files - Update test_validation_strategy.py to import from spec.validation_strategy Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
93 lines
3.6 KiB
Python
93 lines
3.6 KiB
Python
"""
|
|
Tests for thinking level validation in phase_config module.
|
|
|
|
Ensures that invalid thinking levels are caught with proper warnings
|
|
and default to 'medium' as expected.
|
|
"""
|
|
|
|
import logging
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add auto-claude to path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "apps" / "backend"))
|
|
|
|
from phase_config import THINKING_BUDGET_MAP, get_thinking_budget
|
|
|
|
|
|
class TestThinkingLevelValidation:
|
|
"""Test thinking level validation and error handling."""
|
|
|
|
def test_valid_thinking_levels(self):
|
|
"""Test that all valid thinking levels return correct budgets."""
|
|
valid_levels = ["none", "low", "medium", "high", "ultrathink"]
|
|
|
|
for level in valid_levels:
|
|
budget = get_thinking_budget(level)
|
|
expected = THINKING_BUDGET_MAP[level]
|
|
assert budget == expected, f"Expected {expected} for {level}, got {budget}"
|
|
|
|
def test_none_level_returns_none(self):
|
|
"""Test that 'none' thinking level returns None (no extended thinking)."""
|
|
assert get_thinking_budget("none") is None
|
|
|
|
def test_ultrathink_max_budget(self):
|
|
"""Test that 'ultrathink' returns maximum budget (63999 so max_tokens = 63999 + 1 = 64000 limit)."""
|
|
assert get_thinking_budget("ultrathink") == 63999
|
|
|
|
def test_invalid_level_logs_warning(self, caplog):
|
|
"""Test that invalid thinking level logs a warning."""
|
|
with caplog.at_level(logging.WARNING):
|
|
budget = get_thinking_budget("invalid_level")
|
|
|
|
# Should default to medium
|
|
assert budget == THINKING_BUDGET_MAP["medium"]
|
|
|
|
# Should have logged a warning
|
|
assert len(caplog.records) == 1
|
|
assert "Invalid thinking_level 'invalid_level'" in caplog.text
|
|
assert "Valid values:" in caplog.text
|
|
assert "Defaulting to 'medium'" in caplog.text
|
|
|
|
def test_invalid_level_shows_valid_options(self, caplog):
|
|
"""Test that warning message includes all valid options."""
|
|
with caplog.at_level(logging.WARNING):
|
|
get_thinking_budget("bad_value")
|
|
|
|
# Check all valid levels are mentioned
|
|
for level in ["none", "low", "medium", "high", "ultrathink"]:
|
|
assert level in caplog.text
|
|
|
|
def test_empty_string_level(self, caplog):
|
|
"""Test that empty string is treated as invalid."""
|
|
with caplog.at_level(logging.WARNING):
|
|
budget = get_thinking_budget("")
|
|
assert budget == THINKING_BUDGET_MAP["medium"]
|
|
assert "Invalid thinking_level" in caplog.text
|
|
|
|
def test_case_sensitive(self, caplog):
|
|
"""Test that thinking level is case-sensitive."""
|
|
with caplog.at_level(logging.WARNING):
|
|
# "MEDIUM" should be invalid (not "medium")
|
|
budget = get_thinking_budget("MEDIUM")
|
|
assert budget == THINKING_BUDGET_MAP["medium"]
|
|
assert "Invalid thinking_level 'MEDIUM'" in caplog.text
|
|
|
|
def test_multiple_invalid_calls(self, caplog):
|
|
"""Test that each invalid call produces a warning."""
|
|
invalid_levels = ["bad1", "bad2", "bad3"]
|
|
|
|
with caplog.at_level(logging.WARNING):
|
|
for level in invalid_levels:
|
|
get_thinking_budget(level)
|
|
|
|
# Should have 3 warnings
|
|
assert len(caplog.records) == 3
|
|
|
|
def test_budget_values_match_expected(self):
|
|
"""Test that budget values match documented amounts."""
|
|
assert get_thinking_budget("low") == 1024
|
|
assert get_thinking_budget("medium") == 4096
|
|
assert get_thinking_budget("high") == 16384
|
|
assert get_thinking_budget("ultrathink") == 63999
|