Restructure aiservice to language-first architecture (#2383)
## Summary
- Reorganizes `django/aiservice/` from feature-first layout (separate
`optimizer/`, `testgen/`, `code_repair/` dirs) to language-first layout
under `core/languages/{python,js_ts}/`
- Adds handler/registry/dispatcher pattern for routing requests to
language-specific implementations
- All existing module code preserved via `git mv` for history tracking;
no logic changes to existing modules
## What changed
- New `core/` app with registry, dispatcher, protocols, and error
hierarchy
- `PythonHandler` and `JSTypeScriptHandler` delegate to existing module
functions
- All imports updated across the codebase (views, tests,
adaptive_optimizer, etc.)
- Integration tests for handler registration and dispatch
- 155 files changed, ~880 additions / ~207 deletions (mostly import path
updates and moves)
## Test plan
- [ ] `python manage.py check` passes
- [ ] Integration tests in
`tests/integration/test_handler_integration.py` pass
- [ ] Existing test suite passes with updated import paths
- [ ] Ruff and ty clean on all new infrastructure files
---------
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
2026-02-09 14:15:50 +00:00
|
|
|
"""Core infrastructure Django app configuration."""
|
|
|
|
|
|
|
|
|
|
import importlib
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
from django.apps import AppConfig
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CoreConfig(AppConfig):
|
|
|
|
|
"""Django app configuration for the core infrastructure module.
|
|
|
|
|
|
|
|
|
|
This app must be loaded before any feature apps (testgen, optimizer, code_repair)
|
|
|
|
|
to ensure the handler registry is initialized and protocols are available.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
default_auto_field = "django.db.models.BigAutoField"
|
|
|
|
|
name = "core"
|
|
|
|
|
verbose_name = "Core Infrastructure"
|
|
|
|
|
|
|
|
|
|
def ready(self) -> None:
|
|
|
|
|
"""Initialize core infrastructure when Django starts."""
|
|
|
|
|
logger.info("Core app initializing...")
|
|
|
|
|
|
|
|
|
|
# Import language handlers from core.languages
|
|
|
|
|
# This ensures the handlers get registered via their __init__.py
|
|
|
|
|
for module_name, label in [
|
|
|
|
|
("core.languages.python", "Python"),
|
|
|
|
|
("core.languages.js_ts", "JavaScript/TypeScript"),
|
2026-02-13 17:56:55 +00:00
|
|
|
("core.languages.java", "Java"),
|
Restructure aiservice to language-first architecture (#2383)
## Summary
- Reorganizes `django/aiservice/` from feature-first layout (separate
`optimizer/`, `testgen/`, `code_repair/` dirs) to language-first layout
under `core/languages/{python,js_ts}/`
- Adds handler/registry/dispatcher pattern for routing requests to
language-specific implementations
- All existing module code preserved via `git mv` for history tracking;
no logic changes to existing modules
## What changed
- New `core/` app with registry, dispatcher, protocols, and error
hierarchy
- `PythonHandler` and `JSTypeScriptHandler` delegate to existing module
functions
- All imports updated across the codebase (views, tests,
adaptive_optimizer, etc.)
- Integration tests for handler registration and dispatch
- 155 files changed, ~880 additions / ~207 deletions (mostly import path
updates and moves)
## Test plan
- [ ] `python manage.py check` passes
- [ ] Integration tests in
`tests/integration/test_handler_integration.py` pass
- [ ] Existing test suite passes with updated import paths
- [ ] Ruff and ty clean on all new infrastructure files
---------
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
2026-02-09 14:15:50 +00:00
|
|
|
]:
|
|
|
|
|
try:
|
|
|
|
|
importlib.import_module(module_name)
|
|
|
|
|
logger.info("%s language handler imported and registered", label)
|
|
|
|
|
except ImportError:
|
|
|
|
|
logger.warning("Could not import %s language handler", label, exc_info=True)
|
|
|
|
|
|
|
|
|
|
logger.info("Core app initialization complete")
|