# Scenario 3: Fix a Bug in the Optimizer Router and Commit

## Context

A bug has been reported on Linear issue CF-847: the optimizer router in `core/shared/optimizer_router.py` fails to handle the case where `data.language` is `"ts"` (a shorthand some clients send instead of `"typescript"`). This causes a 500 error because the request falls through to the Python handler, which cannot parse TypeScript code.

The fix needs to normalize language aliases before dispatching. The developer should fix the bug, create tests, and commit the changes following the project's git conventions.

## Task

1. Fix the bug in `core/shared/optimizer_router.py`:
   - Add normalization of language aliases (`"ts"` -> `"typescript"`, `"js"` -> `"javascript"`, `"py"` -> `"python"`)
   - Preserve the existing lazy import pattern for dispatch
   - Keep the fix minimal and focused

2. Add a test in `tests/optimizer/test_language_normalization.py`:
   - Test that language aliases are correctly normalized
   - Use `@pytest.mark.asyncio` for async tests
   - Follow the feature-based test organization

3. Commit the changes following git conventions:
   - Create a new branch from `main` named `cf-847-fix-language-alias-normalization`
   - Run pre-commit checks: `uv run prek run --all-files`
   - Make an atomic commit with a conventional commit message (this is a bug fix, so `fix:`)
   - Include `CF-847` reference in the commit body or branch name

## Expected Outputs

- Updated `core/shared/optimizer_router.py` with alias normalization
- New `tests/optimizer/test_language_normalization.py`
- Git branch: `cf-847-fix-language-alias-normalization` (created from `main`)
- Commit message: `fix: normalize language aliases in optimizer router` (or similar conventional format)
- Pre-commit checks passed before commit
