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,7 @@
|
||||
# #region TranslateModels [C:2] [TYPE Module]
|
||||
# #region TranslateModels [C:3] [TYPE Module] [SEMANTICS translate, models, sqlalchemy, persistence]
|
||||
# @BRIEF SQLAlchemy ORM models for LLM-based SQL/dashboard translation across dialects.
|
||||
# @LAYER Domain
|
||||
# @LAYER: Domain
|
||||
# @RELATION INHERITS_FROM -> MappingModels:Base
|
||||
|
||||
from sqlalchemy import (
|
||||
Column, String, Boolean, DateTime, JSON, Text,
|
||||
@@ -13,13 +14,14 @@ import hashlib
|
||||
from .mapping import Base
|
||||
|
||||
|
||||
# #region generate_uuid [C:1] [TYPE Function]
|
||||
def generate_uuid():
|
||||
return str(uuid.uuid4())
|
||||
# #endregion generate_uuid
|
||||
|
||||
|
||||
# #region TranslationJob [C:1] [TYPE Class]
|
||||
# #region TranslationJob [TYPE Class]
|
||||
# @BRIEF A translation job representing a multi-dialect conversion task with column mappings, LLM config, and dictionary attachments.
|
||||
# @RATIONALE: Snapshot isolation — in-progress runs use config snapshot; config edits affect future runs only.
|
||||
# @REJECTED: Invalidating in-progress runs on config edit would break scheduled run continuity.
|
||||
class TranslationJob(Base):
|
||||
__tablename__ = "translation_jobs"
|
||||
|
||||
@@ -51,7 +53,6 @@ class TranslationJob(Base):
|
||||
|
||||
# Environment association
|
||||
environment_id = Column(String, nullable=True, comment="Superset environment ID for datasource access")
|
||||
target_database_id = Column(String, nullable=True, comment="Superset database ID for INSERT via SQL Lab")
|
||||
|
||||
created_by = Column(String, nullable=True)
|
||||
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||
@@ -59,7 +60,8 @@ class TranslationJob(Base):
|
||||
# #endregion TranslationJob
|
||||
|
||||
|
||||
# #region TranslationRun [C:1] [TYPE Class]
|
||||
# #region TranslationRun [TYPE Class]
|
||||
# @BRIEF Represents a single execution of a translation job, capturing status, timing, and Superset execution metadata.
|
||||
class TranslationRun(Base):
|
||||
__tablename__ = "translation_runs"
|
||||
|
||||
@@ -86,7 +88,8 @@ class TranslationRun(Base):
|
||||
# #endregion TranslationRun
|
||||
|
||||
|
||||
# #region TranslationBatch [C:1] [TYPE Class]
|
||||
# #region TranslationBatch [TYPE Class]
|
||||
# @BRIEF Groups translation records within a run into manageable batches with timing and record counts.
|
||||
class TranslationBatch(Base):
|
||||
__tablename__ = "translation_batches"
|
||||
|
||||
@@ -103,7 +106,8 @@ class TranslationBatch(Base):
|
||||
# #endregion TranslationBatch
|
||||
|
||||
|
||||
# #region TranslationRecord [C:1] [TYPE Class]
|
||||
# #region TranslationRecord [TYPE Class]
|
||||
# @BRIEF Individual translation result for a single SQL statement or dashboard element, tracking source, target, and error state.
|
||||
class TranslationRecord(Base):
|
||||
__tablename__ = "translation_records"
|
||||
|
||||
@@ -120,7 +124,6 @@ class TranslationRecord(Base):
|
||||
token_count_input = Column(Integer, nullable=True)
|
||||
token_count_output = Column(Integer, nullable=True)
|
||||
translation_duration_ms = Column(Integer, nullable=True)
|
||||
source_data = Column(JSON, nullable=True, comment="Snapshot of source row key/context column values for INSERT phase")
|
||||
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||
|
||||
__table_args__ = (
|
||||
@@ -129,7 +132,8 @@ class TranslationRecord(Base):
|
||||
# #endregion TranslationRecord
|
||||
|
||||
|
||||
# #region TranslationEvent [C:1] [TYPE Class]
|
||||
# #region TranslationEvent [TYPE Class]
|
||||
# @BRIEF Audit/event log for translation operations, with optional run_id for context.
|
||||
class TranslationEvent(Base):
|
||||
__tablename__ = "translation_events"
|
||||
|
||||
@@ -143,7 +147,8 @@ class TranslationEvent(Base):
|
||||
# #endregion TranslationEvent
|
||||
|
||||
|
||||
# #region TranslationPreviewSession [C:1] [TYPE Class]
|
||||
# #region TranslationPreviewSession [TYPE Class]
|
||||
# @BRIEF A preview session allowing users to review proposed translations before applying them.
|
||||
class TranslationPreviewSession(Base):
|
||||
__tablename__ = "translation_preview_sessions"
|
||||
|
||||
@@ -157,7 +162,8 @@ class TranslationPreviewSession(Base):
|
||||
# #endregion TranslationPreviewSession
|
||||
|
||||
|
||||
# #region TranslationPreviewRecord [C:1] [TYPE Class]
|
||||
# #region TranslationPreviewRecord [TYPE Class]
|
||||
# @BRIEF Individual preview entry within a preview session, showing original and translated content side by side.
|
||||
class TranslationPreviewRecord(Base):
|
||||
__tablename__ = "translation_preview_records"
|
||||
|
||||
@@ -170,12 +176,12 @@ class TranslationPreviewRecord(Base):
|
||||
source_object_name = Column(String, nullable=True)
|
||||
status = Column(String, nullable=False, default="PENDING") # PENDING, APPROVED, REJECTED
|
||||
feedback = Column(Text, nullable=True)
|
||||
source_data = Column(JSON, nullable=True, comment="Snapshot of source row values for key/context columns")
|
||||
created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))
|
||||
# #endregion TranslationPreviewRecord
|
||||
|
||||
|
||||
# #region TerminologyDictionary [C:1] [TYPE Class]
|
||||
# #region TerminologyDictionary [TYPE Class]
|
||||
# @BRIEF A named collection of terminology mappings used during translation to ensure consistent term translation.
|
||||
class TerminologyDictionary(Base):
|
||||
__tablename__ = "terminology_dictionaries"
|
||||
|
||||
@@ -191,7 +197,8 @@ class TerminologyDictionary(Base):
|
||||
# #endregion TerminologyDictionary
|
||||
|
||||
|
||||
# #region DictionaryEntry [C:1] [TYPE Class]
|
||||
# #region DictionaryEntry [TYPE Class]
|
||||
# @BRIEF A single term mapping entry with case-insensitive unique constraint on source_term_normalized and origin tracking.
|
||||
class DictionaryEntry(Base):
|
||||
__tablename__ = "dictionary_entries"
|
||||
|
||||
@@ -216,7 +223,8 @@ class DictionaryEntry(Base):
|
||||
# #endregion DictionaryEntry
|
||||
|
||||
|
||||
# #region TranslationSchedule [C:1] [TYPE Class]
|
||||
# #region TranslationSchedule [TYPE Class]
|
||||
# @BRIEF Defines a cron-based schedule for recurring translation jobs.
|
||||
class TranslationSchedule(Base):
|
||||
__tablename__ = "translation_schedules"
|
||||
|
||||
@@ -233,7 +241,8 @@ class TranslationSchedule(Base):
|
||||
# #endregion TranslationSchedule
|
||||
|
||||
|
||||
# #region TranslationJobDictionary [C:1] [TYPE Class]
|
||||
# #region TranslationJobDictionary [TYPE Class]
|
||||
# @BRIEF Many-to-many association between translation jobs and terminology dictionaries.
|
||||
class TranslationJobDictionary(Base):
|
||||
__tablename__ = "translation_job_dictionaries"
|
||||
|
||||
@@ -251,7 +260,8 @@ class TranslationJobDictionary(Base):
|
||||
# #endregion TranslationJobDictionary
|
||||
|
||||
|
||||
# #region MetricSnapshot [C:1] [TYPE Class]
|
||||
# #region MetricSnapshot [TYPE Class]
|
||||
# @BRIEF Captures translation performance metrics at a point in time with config/content/dictionary hash keys for aggregation.
|
||||
class MetricSnapshot(Base):
|
||||
__tablename__ = "translation_metric_snapshots"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user