semantics: complete DEF-to-region migration, fix regressions
- Convert legacy [DEF🆔Type] anchors to #region/#endregion across 329 files
- Reinstate _normalize_timestamp_value in sql_generator.py
- Fix MarkerLogger→logger migration in events.py (molecular CoT markers)
- Fix dataset_review orchestrator dependencies (_build_execution_snapshot)
- Fix config_manager stale-record deletion (moved to save path only)
- Add 77 missing [/DEF:] closers in 5 unbalanced test files
- Update assistant_chat.integration.test.js for #region format
- Apply molecular-cot-logging markers (REASON/REFLECT/EXPLORE) via logger.* methods
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# #region GitHelpers [C:3] [TYPE Module] [SEMANTICS git, helpers, resolution, identity]
|
||||
# @BRIEF Shared helper functions for Git route modules.
|
||||
# @LAYER API
|
||||
# @LAYER: API
|
||||
# @RELATION USES -> [GitDeps]
|
||||
# @RELATION USES -> [SupersetClient]
|
||||
# @RELATION USES -> [UserDashboardPreference]
|
||||
@@ -11,9 +11,7 @@ from typing import Optional
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from src.core.cot_logger import MarkerLogger
|
||||
|
||||
log = MarkerLogger("GitHelpers")
|
||||
from src.core.logger import logger
|
||||
from src.core.superset_client import SupersetClient
|
||||
from src.dependencies import get_config_manager
|
||||
from src.models.auth import User
|
||||
@@ -25,7 +23,7 @@ from ._deps import get_git_service, MAX_REPOSITORY_STATUS_BATCH
|
||||
|
||||
# #region _build_no_repo_status_payload [C:1] [TYPE Function]
|
||||
# @BRIEF Build a consistent status payload for dashboards without initialized repositories.
|
||||
# @POST Returns a stable payload compatible with frontend repository status parsing.
|
||||
# @POST: Returns a stable payload compatible with frontend repository status parsing.
|
||||
def _build_no_repo_status_payload() -> dict:
|
||||
return {
|
||||
"is_dirty": False,
|
||||
@@ -47,24 +45,24 @@ def _build_no_repo_status_payload() -> dict:
|
||||
|
||||
# #region _handle_unexpected_git_route_error [C:1] [TYPE Function]
|
||||
# @BRIEF Convert unexpected route-level exceptions to stable 500 API responses.
|
||||
# @PRE `error` is a non-HTTPException instance.
|
||||
# @POST Raises HTTPException(500) with route-specific context.
|
||||
# @PRE: `error` is a non-HTTPException instance.
|
||||
# @POST: Raises HTTPException(500) with route-specific context.
|
||||
def _handle_unexpected_git_route_error(route_name: str, error: Exception) -> None:
|
||||
log.explore(f"{route_name} failed: {error}", error=str(error))
|
||||
logger.error(f"[{route_name}][Coherence:Failed] {error}")
|
||||
raise HTTPException(status_code=500, detail=f"{route_name} failed: {str(error)}")
|
||||
# #endregion _handle_unexpected_git_route_error
|
||||
|
||||
|
||||
# #region _resolve_repository_status [C:2] [TYPE Function]
|
||||
# @BRIEF Resolve repository status for one dashboard with graceful NO_REPO semantics.
|
||||
# @PRE `dashboard_id` is a valid integer.
|
||||
# @POST Returns standard status payload or `NO_REPO` payload when repository path is absent.
|
||||
# @PRE: `dashboard_id` is a valid integer.
|
||||
# @POST: Returns standard status payload or `NO_REPO` payload when repository path is absent.
|
||||
def _resolve_repository_status(dashboard_id: int) -> dict:
|
||||
git_service = get_git_service()
|
||||
repo_path = git_service._get_repo_path(dashboard_id)
|
||||
if not os.path.exists(repo_path):
|
||||
log.reason(
|
||||
f"Repository is not initialized for dashboard {dashboard_id}"
|
||||
logger.debug(
|
||||
f"[get_repository_status][Action] Repository is not initialized for dashboard {dashboard_id}"
|
||||
)
|
||||
return _build_no_repo_status_payload()
|
||||
|
||||
@@ -72,8 +70,8 @@ def _resolve_repository_status(dashboard_id: int) -> dict:
|
||||
return git_service.get_status(dashboard_id)
|
||||
except HTTPException as e:
|
||||
if e.status_code == 404:
|
||||
log.reason(
|
||||
f"Repository is not initialized for dashboard {dashboard_id}"
|
||||
logger.debug(
|
||||
f"[get_repository_status][Action] Repository is not initialized for dashboard {dashboard_id}"
|
||||
)
|
||||
return _build_no_repo_status_payload()
|
||||
raise
|
||||
@@ -289,7 +287,11 @@ def _resolve_current_user_git_identity(
|
||||
.first()
|
||||
)
|
||||
except Exception as resolve_error:
|
||||
log.explore(f"Failed to load profile preference for user {user_id}: {resolve_error}", error=str(resolve_error))
|
||||
logger.warning(
|
||||
"[_resolve_current_user_git_identity][Action] Failed to load profile preference for user %s: %s",
|
||||
user_id,
|
||||
resolve_error,
|
||||
)
|
||||
return None
|
||||
|
||||
if not preference:
|
||||
|
||||
Reference in New Issue
Block a user