fix(llm): add fetch-models endpoint, fix SQL Lab INSERT (client_id truncation, sync mode, target_column, timestamp normalization)

- Add POST /api/llm/providers/fetch-models route with LLMClient.fetch_models()
- Add target_column to TranslationJob model/schema/service/orchestrator
- Fix SQL Lab execute: truncate client_id to 11 chars (varchar(11))
- Switch SQL Lab to sync mode (runAsync: false) — no Celery workers
- Fix polling: unwrap nested result from Superset query API
- Fix ClickHouse timestamp: normalize float timestamps to YYYY-MM-DD
This commit is contained in:
2026-05-13 20:06:15 +03:00
parent 39ab647851
commit a3c7c402b7
276 changed files with 1923 additions and 1822 deletions

View File

@@ -1,6 +1,5 @@
# [DEF:TestArchiveParser:Module]
#
# @COMPLEXITY: 3
# @PURPOSE: Unit tests for MigrationArchiveParser ZIP extraction contract.
# @LAYER: Domain
# @RELATION: DEPENDS_ON -> [MigrationArchiveParserModule]

View File

@@ -1,6 +1,5 @@
# [DEF:TestDryRunOrchestrator:Module]
#
# @COMPLEXITY: 3
# @PURPOSE: Unit tests for MigrationDryRunService diff and risk computation contracts.
# @LAYER: Domain
# @RELATION: DEPENDS_ON -> [MigrationDryRunOrchestratorModule]

View File

@@ -1,6 +1,5 @@
# [DEF:TestGitServiceGiteaPr:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 3
# @SEMANTICS: tests, git, gitea, pull_request, fallback
# @PURPOSE: Validate Gitea PR creation fallback behavior when configured server URL is stale.
# @LAYER: Domain

View File

@@ -1,6 +1,5 @@
# [DEF:TestMappingService:Module]
#
# @COMPLEXITY: 3
# @PURPOSE: Unit tests for the IdMappingService matching UUIDs to integer IDs.
# @LAYER: Domain
# @RELATION: VERIFIES ->[src.core.mapping_service.IdMappingService]

View File

@@ -1,6 +1,5 @@
# [DEF:TestMigrationEngine:Module]
#
# @COMPLEXITY: 3
# @PURPOSE: Unit tests for MigrationEngine's cross-filter patching algorithms.
# @LAYER: Domain
# @RELATION: VERIFIES -> [src.core.migration_engine:Module]
@@ -29,7 +28,6 @@ from src.models.mapping import ResourceType
# [DEF:MockMappingService:Class]
# @RELATION: BINDS_TO -> [TestMigrationEngine:Module]
# @COMPLEXITY: 2
# @PURPOSE: Deterministic mapping service double for native filter ID remapping scenarios.
# @INVARIANT: Returns mappings only for requested UUID keys present in seeded map.
class MockMappingService:

View File

@@ -1,6 +1,5 @@
# [DEF:test_clean_release_cli:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 3
# @PURPOSE: Smoke tests for the redesigned clean release CLI.
# @LAYER: Domain

View File

@@ -1,6 +1,5 @@
# [DEF:TestCleanReleaseTui:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 3
# @SEMANTICS: tests, tui, clean-release, curses
# @PURPOSE: Unit tests for the interactive curses TUI of the clean release process.
# @LAYER: Scripts

View File

@@ -1,6 +1,5 @@
# [DEF:test_clean_release_tui_v2:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 3
# @PURPOSE: Smoke tests for thin-client TUI action dispatch and blocked transition behavior.
# @LAYER: Domain

View File

@@ -1,6 +1,5 @@
# [DEF:TestApprovalService:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 5
# @SEMANTICS: tests, clean-release, approval, lifecycle, gate
# @PURPOSE: Define approval gate contracts for approve/reject operations over immutable compliance evidence.
# @LAYER: Tests

View File

@@ -1,6 +1,5 @@
# [DEF:test_candidate_manifest_services:Module]
# @RELATION: BELONGS_TO -> [SrcRoot:Module]
# @COMPLEXITY: 3
# @PURPOSE: Test lifecycle and manifest versioning for release candidates.
# @LAYER: Tests

View File

@@ -1,6 +1,5 @@
# [DEF:TestComplianceExecutionService:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 5
# @SEMANTICS: tests, clean-release, compliance, pipeline, run-finalization
# @PURPOSE: Validate stage pipeline and run finalization contracts for compliance execution.
# @LAYER: Tests

View File

@@ -1,6 +1,5 @@
# [DEF:TestComplianceTaskIntegration:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 5
# @SEMANTICS: tests, clean-release, compliance, task-manager, integration
# @PURPOSE: Verify clean release compliance runs execute through TaskManager lifecycle with observable success/failure outcomes.
# @LAYER: Tests
@@ -144,7 +143,6 @@ class CleanReleaseCompliancePlugin:
# [DEF:_PluginLoaderStub:Class]
# @RELATION: BINDS_TO -> TestComplianceTaskIntegration
# @COMPLEXITY: 2
# @PURPOSE: Provide minimal plugin loader contract used by TaskManager in integration tests.
# @INVARIANT: has_plugin/get_plugin only acknowledge the seeded compliance plugin id.
class _PluginLoaderStub:

View File

@@ -1,5 +1,4 @@
# [DEF:TestDemoModeIsolation:Module]
# @COMPLEXITY: 3
# @SEMANTICS: clean-release, demo-mode, isolation, namespace, repository
# @PURPOSE: Verify demo and real mode namespace isolation contracts before TUI integration.
# @LAYER: Tests

View File

@@ -1,5 +1,4 @@
# [DEF:TestPolicyResolutionService:Module]
# @COMPLEXITY: 5
# @SEMANTICS: clean-release, policy-resolution, trusted-snapshots, contracts
# @PURPOSE: Verify trusted policy snapshot resolution contract and error guards.
# @LAYER: Tests
@@ -24,7 +23,6 @@ from src.services.clean_release.repository import CleanReleaseRepository
# [DEF:_config_manager:Function]
# @RELATION: BINDS_TO -> [TestPolicyResolutionService]
# @COMPLEXITY: 1
# @PURPOSE: Build deterministic ConfigManager-like stub for tests.
# @INVARIANT: Only settings.clean_release.active_policy_id and active_registry_id are populated; any other settings field access raises AttributeError.
# @PRE: policy_id and registry_id may be None or non-empty strings.

View File

@@ -1,6 +1,5 @@
# [DEF:TestPublicationService:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 5
# @SEMANTICS: tests, clean-release, publication, revoke, gate
# @PURPOSE: Define publication gate contracts over approved candidates and immutable publication records.
# @LAYER: Tests

View File

@@ -1,6 +1,5 @@
# [DEF:TestReportAuditImmutability:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 5
# @SEMANTICS: tests, clean-release, report, audit, immutability, append-only
# @PURPOSE: Validate report snapshot immutability expectations and append-only audit hook behavior for US2.
# @LAYER: Tests

View File

@@ -1,5 +1,4 @@
# [DEF:SupersetCompatibilityMatrixTests:Module]
# @COMPLEXITY: 3
# @SEMANTICS: dataset_review, superset, compatibility_matrix, preview, sql_lab, tests
# @PURPOSE: Verifies Superset preview and SQL Lab endpoint fallback strategy used by dataset-review orchestration.
# @LAYER: Tests
@@ -21,7 +20,6 @@ from src.core.utils.superset_compilation_adapter import (
# [DEF:make_adapter:Function]
# @COMPLEXITY: 2
# @PURPOSE: Build an adapter with a mock Superset client and deterministic environment for compatibility tests.
# @RELATION: [DEPENDS_ON] ->[SupersetCompilationAdapter]
def make_adapter():
@@ -43,7 +41,6 @@ def make_adapter():
# [DEF:test_preview_prefers_supported_client_method_before_network_fallback:Function]
# @COMPLEXITY: 2
# @PURPOSE: Confirms preview compilation uses a supported client method first when the capability exists.
# @RELATION: [DEPENDS_ON] ->[SupersetCompilationAdapter]
def test_preview_prefers_supported_client_method_before_network_fallback():
@@ -69,7 +66,6 @@ def test_preview_prefers_supported_client_method_before_network_fallback():
# [DEF:test_preview_falls_back_across_matrix_until_supported_endpoint_returns_sql:Function]
# @COMPLEXITY: 3
# @PURPOSE: Confirms preview fallback walks the compatibility matrix from preferred to legacy endpoints until one returns compiled SQL.
# @RELATION: [DEPENDS_ON] ->[SupersetCompilationAdapter]
def test_preview_falls_back_across_matrix_until_supported_endpoint_returns_sql():
@@ -104,7 +100,6 @@ def test_preview_falls_back_across_matrix_until_supported_endpoint_returns_sql()
# [DEF:test_sql_lab_launch_falls_back_to_legacy_execute_endpoint:Function]
# @COMPLEXITY: 3
# @PURPOSE: Confirms SQL Lab launch falls back from modern to legacy execute endpoint and preserves canonical session reference extraction.
# @RELATION: [DEPENDS_ON] ->[SupersetCompilationAdapter]
def test_sql_lab_launch_falls_back_to_legacy_execute_endpoint():

View File

@@ -1,5 +1,4 @@
# [DEF:TestAuth:Module]
# @COMPLEXITY: 3
# @PURPOSE: Covers authentication service/repository behavior and auth bootstrap helpers.
# @LAYER: Test
# @RELATION: TESTS -> AuthService

View File

@@ -1,6 +1,5 @@
# [DEF:TestDashboardsApi:Module]
# @RELATION: VERIFIES ->[src.api.routes.dashboards]
# @COMPLEXITY: 3
# @PURPOSE: Comprehensive contract-driven tests for Dashboard Hub API
# @LAYER: Domain (Tests)
# @SEMANTICS: tests, dashboards, api, contract, remediation
@@ -561,7 +560,7 @@ def test_backup_dashboards_with_schedule(mock_deps):
# --- 8. Internal logic: _task_matches_dashboard ---
# [/DEF:test_backup_dashboards_with_schedule:Function]
from src.api.routes.dashboards import _task_matches_dashboard
from src.api.routes.dashboards._projection import _task_matches_dashboard
# [DEF:test_task_matches_dashboard_logic:Function]

View File

@@ -3,7 +3,6 @@
# @SEMANTICS: test, log, persistence, unit_test
# @PURPOSE: Unit tests for TaskLogPersistenceService.
# @LAYER: Test
# @COMPLEXITY: 5
# [SECTION: IMPORTS]
from datetime import datetime
@@ -20,7 +19,6 @@ from src.core.task_manager.models import LogEntry, LogFilter
# [DEF:TestLogPersistence:Class]
# @RELATION: BINDS_TO -> test_log_persistence
# @PURPOSE: Test suite for TaskLogPersistenceService.
# @COMPLEXITY: 5
# @TEST_DATA: log_entry -> {"task_id": "test-task-1", "level": "INFO", "source": "test_source", "message": "Test message"}
class TestLogPersistence:

View File

@@ -1,5 +1,4 @@
# [DEF:TestLogger:Module]
# @COMPLEXITY: 3
# @SEMANTICS: logging, tests, belief_state, cot, json
# @PURPOSE: Unit tests for the custom logger CoT JSON formatters and configuration context manager.
# @LAYER: Logging (Tests)

View File

@@ -1,7 +1,6 @@
# [DEF:TestResourceHubs:Module]
# @RELATION: DEPENDS_ON -> [DashboardsApi]
# @RELATION: DEPENDS_ON -> [DatasetsApi]
# @COMPLEXITY: 3
# @SEMANTICS: tests, resource-hubs, dashboards, datasets, pagination, api
# @PURPOSE: Contract tests for resource hub dashboards/datasets listing and pagination boundary validation.
# @LAYER: Domain (Tests)

View File

@@ -1,5 +1,4 @@
# [DEF:TestSmokeApp:Module]
# @COMPLEXITY: 2
# @SEMANTICS: tests, smoke, app, imports, fastapi
# @PURPOSE: Minimal smoke tests that verify the full application import chain
# succeeds without SyntaxError, IndentationError, ImportError, or

View File

@@ -1,6 +1,5 @@
# [DEF:test_task_manager:Module]
# @RELATION: BELONGS_TO -> SrcRoot
# @COMPLEXITY: 5
# @SEMANTICS: task-manager, lifecycle, CRUD, log-buffer, filtering, tests
# @PURPOSE: Unit tests for TaskManager lifecycle, CRUD, log buffering, and filtering.
# @LAYER: Core

View File

@@ -3,7 +3,6 @@
# @SEMANTICS: test, task, persistence, unit_test
# @PURPOSE: Unit tests for TaskPersistenceService.
# @LAYER: Test
# @COMPLEXITY: 5
# @TEST_DATA: valid_task -> {"id": "test-uuid-1", "plugin_id": "backup", "status": "PENDING"}
# [SECTION: IMPORTS]
@@ -23,7 +22,6 @@ from src.core.task_manager.models import Task, TaskStatus, LogEntry
# [DEF:TestTaskPersistenceHelpers:Class]
# @RELATION: BINDS_TO -> test_task_persistence
# @PURPOSE: Test suite for TaskPersistenceService static helper methods.
# @COMPLEXITY: 5
class TestTaskPersistenceHelpers:
# [DEF:test_json_load_if_needed_none:Function]
@@ -113,7 +111,6 @@ class TestTaskPersistenceHelpers:
# [DEF:TestTaskPersistenceService:Class]
# @RELATION: BINDS_TO -> test_task_persistence
# @PURPOSE: Test suite for TaskPersistenceService CRUD operations.
# @COMPLEXITY: 5
# @TEST_DATA: valid_task -> {"id": "test-uuid-1", "plugin_id": "backup", "status": "PENDING"}
class TestTaskPersistenceService:

View File

@@ -1,5 +1,4 @@
# [DEF:TranslateCorrectionTests:Module]
# @COMPLEXITY: 4
# @SEMANTICS: tests, translate, corrections, dictionary
# @PURPOSE: Tests for term correction API endpoints and DictionaryManager correction methods.
# @LAYER: Test

View File

@@ -1,5 +1,4 @@
# [DEF:TranslateHistoryTests:Module]
# @COMPLEXITY: 4
# @SEMANTICS: tests, translate, history, metrics
# @PURPOSE: Tests for run history list/detail endpoints and metrics aggregation.
# @LAYER: Test

View File

@@ -1,5 +1,4 @@
# [DEF:TranslateJobTests:Module]
# @COMPLEXITY: 4
# @SEMANTICS: tests, translate, jobs, crud, validation
# @PURPOSE: Tests for translation job CRUD endpoints and service layer with column validation.
# @LAYER: Test

View File

@@ -1,5 +1,4 @@
# [DEF:TranslateSchedulerTests:Module]
# @COMPLEXITY: 4
# @SEMANTICS: tests, translate, scheduler
# @PURPOSE: Tests for TranslationScheduler CRUD and APScheduler integration.
# @LAYER: Test