semantics

This commit is contained in:
2026-05-26 09:30:41 +03:00
parent 1e7bcecaea
commit 9ffa8af1dc
623 changed files with 28045 additions and 26557 deletions

View File

@@ -1,5 +1,5 @@
# #region TestCleanReleaseModels [TYPE Module] [SEMANTICS test, clean-release, model, contract]
# @RELATION VERIFIES -> [CleanReleaseModels]
# @RELATION BINDS_TO -> [CleanReleaseModels]
# @BRIEF Contract testing for Clean Release models
# #endregion TestCleanReleaseModels
from datetime import datetime
@@ -24,7 +24,7 @@ from src.models.clean_release import (
)
# @TEST_FIXTURE: valid_enterprise_candidate
# @TEST_FIXTURE valid_enterprise_candidate
@pytest.fixture
def valid_candidate_data():
return {
@@ -50,7 +50,7 @@ def test_release_candidate_empty_id(valid_candidate_data):
valid_candidate_data["candidate_id"] = " "
with pytest.raises(ValueError, match="candidate_id must be non-empty"):
ReleaseCandidate(**valid_candidate_data)
# @TEST_FIXTURE: valid_enterprise_policy
# @TEST_FIXTURE valid_enterprise_policy
# #endregion test_release_candidate_empty_id
@pytest.fixture
def valid_policy_data():
@@ -64,14 +64,14 @@ def valid_policy_data():
"effective_from": datetime.now(),
"profile": ProfileType.ENTERPRISE_CLEAN,
}
# @TEST_INVARIANT: policy_purity
# @TEST_INVARIANT policy_purity
# #region test_enterprise_policy_valid [TYPE Function]
# @RELATION BINDS_TO -> [TestCleanReleaseModels]
# @BRIEF Verify that a valid enterprise policy is accepted.
def test_enterprise_policy_valid(valid_policy_data):
policy = CleanProfilePolicy(**valid_policy_data)
assert policy.external_source_forbidden is True
# @TEST_EDGE: enterprise_policy_missing_prohibited
# @TEST_EDGE enterprise_policy_missing_prohibited
# #endregion test_enterprise_policy_valid
# #region test_enterprise_policy_missing_prohibited [TYPE Function]
# @RELATION BINDS_TO -> [TestCleanReleaseModels]
@@ -83,7 +83,7 @@ def test_enterprise_policy_missing_prohibited(valid_policy_data):
match="enterprise-clean policy requires prohibited_artifact_categories",
):
CleanProfilePolicy(**valid_policy_data)
# @TEST_EDGE: enterprise_policy_external_allowed
# @TEST_EDGE enterprise_policy_external_allowed
# #endregion test_enterprise_policy_missing_prohibited
# #region test_enterprise_policy_external_allowed [TYPE Function]
# @RELATION BINDS_TO -> [TestCleanReleaseModels]
@@ -95,8 +95,8 @@ def test_enterprise_policy_external_allowed(valid_policy_data):
match="enterprise-clean policy requires external_source_forbidden=true",
):
CleanProfilePolicy(**valid_policy_data)
# @TEST_INVARIANT: manifest_consistency
# @TEST_EDGE: manifest_count_mismatch
# @TEST_INVARIANT manifest_consistency
# @TEST_EDGE manifest_count_mismatch
# #endregion test_enterprise_policy_external_allowed
# #region test_manifest_count_mismatch [TYPE Function]
# @RELATION BINDS_TO -> [TestCleanReleaseModels]
@@ -134,8 +134,8 @@ def test_manifest_count_mismatch():
summary=summary,
deterministic_hash="h",
)
# @TEST_INVARIANT: run_integrity
# @TEST_EDGE: compliant_run_stage_fail
# @TEST_INVARIANT run_integrity
# @TEST_EDGE compliant_run_stage_fail
# #endregion test_manifest_count_mismatch
# #region test_compliant_run_validation [TYPE Function]
# @RELATION BINDS_TO -> [TestCleanReleaseModels]

View File

@@ -1,7 +1,7 @@
# #region test_models [TYPE Module] [C:1] [SEMANTICS test, model, sqlalchemy, unit]
# @BRIEF Unit tests for data models
# @LAYER: Domain
# @RELATION VERIFIES -> [ModelsPackage]
# @LAYER Domain
# @RELATION BINDS_TO -> [ModelsPackage]
from pathlib import Path
import sys
@@ -14,8 +14,8 @@ from src.core.logger import belief_scope
# #region test_environment_model [TYPE Function]
# @RELATION BINDS_TO -> test_models
# @BRIEF Tests that Environment model correctly stores values.
# @PRE: Environment class is available.
# @POST: Values are verified.
# @PRE Environment class is available.
# @POST Values are verified.
def test_environment_model():
with belief_scope("test_environment_model"):
env = Environment(

View File

@@ -1,7 +1,7 @@
# #region test_report_models [TYPE Module] [C:3] [SEMANTICS test, report, model, pydantic, validator]
# @RELATION BELONGS_TO -> SrcRoot
# @RELATION BINDS_TO -> SrcRoot
# @BRIEF Unit tests for report Pydantic models and their validators
# @LAYER: Domain
# @LAYER Domain
from pathlib import Path
import sys

View File

@@ -1,10 +1,10 @@
# #region AssistantModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, assistant, model, schema, audit, assistant-audit-record]
# @BRIEF SQLAlchemy models for assistant audit trail and confirmation tokens.
# @LAYER: Domain
# @LAYER Domain
# @RELATION DEPENDS_ON -> MappingModels
# @INVARIANT: Assistant records preserve immutable ids and creation timestamps.
# @SIDE_EFFECT: Defines assistant audit/message/confirmation tables
# @DATA_CONTRACT: AssistantData -> AssistantRecord
# @INVARIANT Assistant records preserve immutable ids and creation timestamps.
# @SIDE_EFFECT Defines assistant audit/message/confirmation tables
# @DATA_CONTRACT AssistantData -> AssistantRecord
from datetime import datetime
@@ -16,8 +16,8 @@ from .mapping import Base
# #region AssistantAuditRecord [C:3] [TYPE Class]
# @BRIEF Store audit decisions and outcomes produced by assistant command handling.
# @RELATION INHERITS -> MappingModels
# @PRE: user_id must identify the actor for every record.
# @POST: Audit payload remains available for compliance and debugging.
# @PRE user_id must identify the actor for every record.
# @POST Audit payload remains available for compliance and debugging.
class AssistantAuditRecord(Base):
__tablename__ = "assistant_audit"
@@ -37,8 +37,8 @@ class AssistantAuditRecord(Base):
# #region AssistantMessageRecord [C:3] [TYPE Class]
# @BRIEF Persist chat history entries for assistant conversations.
# @RELATION INHERITS -> MappingModels
# @PRE: user_id, conversation_id, role and text must be present.
# @POST: Message row can be queried in chronological order.
# @PRE user_id, conversation_id, role and text must be present.
# @POST Message row can be queried in chronological order.
class AssistantMessageRecord(Base):
__tablename__ = "assistant_messages"
@@ -60,8 +60,8 @@ class AssistantMessageRecord(Base):
# #region AssistantConfirmationRecord [C:3] [TYPE Class]
# @BRIEF Persist risky operation confirmation tokens with lifecycle state.
# @RELATION INHERITS -> MappingModels
# @PRE: intent/dispatch and expiry timestamp must be provided.
# @POST: State transitions can be tracked and audited.
# @PRE intent/dispatch and expiry timestamp must be provided.
# @POST State transitions can be tracked and audited.
class AssistantConfirmationRecord(Base):
__tablename__ = "assistant_confirmations"

View File

@@ -1,13 +1,13 @@
# #region AuthModels [C:5] [TYPE Module] [SEMANTICS sqlalchemy, auth, model, schema, user]
# @BRIEF SQLAlchemy models for multi-user authentication and authorization.
# @LAYER: Domain
# @RELATION INHERITS_FROM -> [Base]
# @LAYER Domain
# @RELATION INHERITS -> [EXT:Library:SQLAlchemy.Base]
#
# @INVARIANT: Usernames and emails must be unique.
# @PRE: Database engine initialized
# @POST: Auth ORM models registered with unique constraints
# @SIDE_EFFECT: Defines auth user tables
# @DATA_CONTRACT: UserData -> UserRecord
# @INVARIANT Usernames and emails must be unique.
# @PRE Database engine initialized
# @POST Auth ORM models registered with unique constraints
# @SIDE_EFFECT Defines auth user tables
# @DATA_CONTRACT UserData -> UserRecord
from datetime import datetime
import uuid
@@ -20,8 +20,8 @@ from .mapping import Base
# #region generate_uuid [TYPE Function]
# @BRIEF Generates a unique UUID string.
# @POST: Returns a string representation of a new UUID.
# @RELATION DEPENDS_ON -> [uuid]
# @POST Returns a string representation of a new UUID.
# @RELATION DEPENDS_ON -> [EXT:Python:uuid]
def generate_uuid():
return str(uuid.uuid4())
@@ -30,7 +30,7 @@ def generate_uuid():
# #region user_roles [TYPE Table]
# @BRIEF Association table for many-to-many relationship between Users and Roles.
# @RELATION DEPENDS_ON -> [Base]
# @RELATION DEPENDS_ON -> [EXT:Library:SQLAlchemy.Base]
# @RELATION DEPENDS_ON -> [User]
# @RELATION DEPENDS_ON -> [Role]
user_roles = Table(
@@ -43,7 +43,7 @@ user_roles = Table(
# #region role_permissions [TYPE Table]
# @BRIEF Association table for many-to-many relationship between Roles and Permissions.
# @RELATION DEPENDS_ON -> [Base]
# @RELATION DEPENDS_ON -> [EXT:Library:SQLAlchemy.Base]
# @RELATION DEPENDS_ON -> [Role]
# @RELATION DEPENDS_ON -> [Permission]
role_permissions = Table(
@@ -57,7 +57,7 @@ role_permissions = Table(
# #region User [TYPE Class]
# @BRIEF Represents an identity that can authenticate to the system.
# @RELATION HAS_MANY -> [Role]
# @RELATION BINDS_TO -> [Role]
class User(Base):
__tablename__ = "users"
@@ -80,8 +80,8 @@ class User(Base):
# #region Role [TYPE Class]
# @BRIEF Represents a collection of permissions.
# @RELATION HAS_MANY -> [User]
# @RELATION HAS_MANY -> [Permission]
# @RELATION BINDS_TO -> [User]
# @RELATION BINDS_TO -> [Permission]
class Role(Base):
__tablename__ = "roles"
@@ -100,7 +100,7 @@ class Role(Base):
# #region Permission [TYPE Class]
# @BRIEF Represents a specific capability within the system.
# @RELATION HAS_MANY -> [Role]
# @RELATION BINDS_TO -> [Role]
class Permission(Base):
__tablename__ = "permissions"

View File

@@ -1,12 +1,12 @@
# #region CleanReleaseModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, clean-release, model, schema, schedule, release]
# @BRIEF Define canonical clean release domain entities and lifecycle guards.
# @LAYER: Domain
# @LAYER Domain
# @RELATION DEPENDS_ON -> MappingModels
# @PRE: Base mapping model and release enums are available.
# @POST: Provides SQLAlchemy and dataclass definitions for governance domain.
# @SIDE_EFFECT: None (schema definition).
# @DATA_CONTRACT: Model[ReleaseCandidate, CandidateArtifact, DistributionManifest, ComplianceRun, ComplianceReport]
# @INVARIANT: Immutable snapshots are never mutated; forbidden lifecycle transitions are rejected.
# @PRE Base mapping model and release enums are available.
# @POST Provides SQLAlchemy and dataclass definitions for governance domain.
# @SIDE_EFFECT None (schema definition).
# @DATA_CONTRACT Model[ReleaseCandidate, CandidateArtifact, DistributionManifest, ComplianceRun, ComplianceReport]
# @INVARIANT Immutable snapshots are never mutated; forbidden lifecycle transitions are rejected.
from datetime import datetime
from enum import Enum
@@ -227,8 +227,8 @@ class ComplianceCheckRun:
# #region ReleaseCandidate [TYPE Class]
# @BRIEF Represents the release unit being prepared and governed.
# @PRE: id, version, source_snapshot_ref are non-empty.
# @POST: status advances only through legal transitions.
# @PRE id, version, source_snapshot_ref are non-empty.
# @POST status advances only through legal transitions.
class ReleaseCandidate(Base):
__tablename__ = "clean_release_candidates"
@@ -324,7 +324,7 @@ class ManifestSummary:
# #region DistributionManifest [TYPE Class]
# @BRIEF Immutable snapshot of the candidate payload.
# @INVARIANT: Immutable after creation.
# @INVARIANT Immutable after creation.
class DistributionManifest(Base):
__tablename__ = "clean_release_manifests"
@@ -575,7 +575,7 @@ class ComplianceViolation(Base):
# #region ComplianceReport [TYPE Class]
# @BRIEF Immutable result derived from a completed run.
# @INVARIANT: Immutable after creation.
# @INVARIANT Immutable after creation.
class ComplianceReport(Base):
__tablename__ = "clean_release_compliance_reports"

View File

@@ -1,10 +1,10 @@
# #region ConfigModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, model, schema, notification, app-config-record]
#
# @BRIEF Defines SQLAlchemy persistence models for application and notification configuration records.
# @LAYER: Domain
# @LAYER Domain
# @RELATION DEPENDS_ON -> [MappingModels:Base]
# @INVARIANT: Configuration payload and notification credentials must remain persisted as non-null JSON documents.
# @RELATION DEPENDS_ON -> [EXT:internal:MappingModels:Base]
# @INVARIANT Configuration payload and notification credentials must remain persisted as non-null JSON documents.
from sqlalchemy import JSON, Boolean, Column, DateTime, String
from sqlalchemy.sql import func
@@ -14,10 +14,10 @@ from .mapping import Base
# #region AppConfigRecord [TYPE Class]
# @BRIEF Stores persisted application configuration as a single authoritative record model.
# @PRE: SQLAlchemy declarative Base is initialized and table metadata registration is active.
# @POST: ORM table 'app_configurations' exposes id, payload, and updated_at fields with declared nullability/default semantics.
# @SIDE_EFFECT: Registers ORM mapping metadata during module import.
# @DATA_CONTRACT: Input -> persistence row {id:str, payload:json, updated_at:datetime}; Output -> AppConfigRecord ORM entity.
# @PRE SQLAlchemy declarative Base is initialized and table metadata registration is active.
# @POST ORM table 'app_configurations' exposes id, payload, and updated_at fields with declared nullability/default semantics.
# @SIDE_EFFECT Registers ORM mapping metadata during module import.
# @DATA_CONTRACT Input -> persistence row {id:str, payload:json, updated_at:datetime}; Output -> AppConfigRecord ORM entity.
class AppConfigRecord(Base):
__tablename__ = "app_configurations"
@@ -30,10 +30,10 @@ class AppConfigRecord(Base):
# #region NotificationConfig [TYPE Class]
# @BRIEF Stores persisted provider-level notification configuration and encrypted credentials metadata.
# @PRE: SQLAlchemy declarative Base is initialized and uuid generation is available at instance creation time.
# @POST: ORM table 'notification_configs' exposes id, type, name, credentials, is_active, created_at, updated_at fields with declared constraints/defaults.
# @SIDE_EFFECT: Registers ORM mapping metadata during module import; may generate UUID values for new entity instances.
# @DATA_CONTRACT: Input -> persistence row {id:str, type:str, name:str, credentials:json, is_active:bool, created_at:datetime, updated_at:datetime}; Output -> NotificationConfig ORM entity.
# @PRE SQLAlchemy declarative Base is initialized and uuid generation is available at instance creation time.
# @POST ORM table 'notification_configs' exposes id, type, name, credentials, is_active, created_at, updated_at fields with declared constraints/defaults.
# @SIDE_EFFECT Registers ORM mapping metadata during module import; may generate UUID values for new entity instances.
# @DATA_CONTRACT Input -> persistence row {id:str, type:str, name:str, credentials:json, is_active:bool, created_at:datetime, updated_at:datetime}; Output -> NotificationConfig ORM entity.
class NotificationConfig(Base):
__tablename__ = "notification_configs"

View File

@@ -1,7 +1,7 @@
# #region DashboardModels [C:3] [TYPE Module] [SEMANTICS pydantic, dashboard, model, schema, selection, dashboard-metadata]
# @BRIEF Defines data models for dashboard metadata and selection.
# @LAYER: Model
# @RELATION USED_BY -> MigrationApi
# @LAYER Domain
# @RELATION CALLED_BY -> [MigrationApi]
from pydantic import BaseModel

View File

@@ -1,18 +1,18 @@
# #region DatasetReviewModels [C:2] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, model, schema, facade]
# @BRIEF Thin facade re-exporting all dataset review domain models from the decomposed sub-package.
# @LAYER: Domain
# @RELATION EXPORTS -> [DatasetReviewEnums:Module]
# @RELATION EXPORTS -> [DatasetReviewSessionModels:Module]
# @RELATION EXPORTS -> [DatasetReviewProfileModels:Module]
# @RELATION EXPORTS -> [DatasetReviewFindingModels:Module]
# @RELATION EXPORTS -> [DatasetReviewSemanticModels:Module]
# @RELATION EXPORTS -> [DatasetReviewFilterModels:Module]
# @RELATION EXPORTS -> [DatasetReviewMappingModels:Module]
# @RELATION EXPORTS -> [DatasetReviewClarificationModels:Module]
# @RELATION EXPORTS -> [DatasetReviewExecutionModels:Module]
# @INVARIANT: All public model classes and enums remain importable from `src.models.dataset_review` without changes.
# @RATIONALE: Original 984-line monolith violated INV_7 (400-line module limit). Decomposed into domain-focused sub-modules while preserving backward-compatible import paths.
# @REJECTED: Keeping all models in a single file because it exceeded the fractal limit by 2.5x and accumulated structural erosion risk.
# @LAYER Domain
# @RELATION CALLS -> [DatasetReviewEnums]
# @RELATION CALLS -> [DatasetReviewSessionModels]
# @RELATION CALLS -> [DatasetReviewProfileModels]
# @RELATION CALLS -> [DatasetReviewFindingModels]
# @RELATION CALLS -> [DatasetReviewSemanticModels]
# @RELATION CALLS -> [DatasetReviewFilterModels]
# @RELATION CALLS -> [DatasetReviewMappingModels]
# @RELATION CALLS -> [DatasetReviewClarificationModels]
# @RELATION CALLS -> [DatasetReviewExecutionModels]
# @INVARIANT All public model classes and enums remain importable from `src.models.dataset_review` without changes.
# @RATIONALE Original 984-line monolith violated INV_7 (400-line module limit). Decomposed into domain-focused sub-modules while preserving backward-compatible import paths.
# @REJECTED Keeping all models in a single file because it exceeded the fractal limit by 2.5x and accumulated structural erosion risk.
from src.models.dataset_review_pkg._clarification_models import ( # noqa: F401
ClarificationAnswer,

View File

@@ -1,6 +1,6 @@
# #region DatasetReviewModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, model, schema, package]
# @BRIEF Re-export all dataset review domain models from decomposed sub-modules for backward-compatible imports.
# @LAYER: Domain
# @LAYER Domain
from src.models.dataset_review_pkg._clarification_models import (
ClarificationAnswer,

View File

@@ -1,13 +1,13 @@
# #region DatasetReviewClarificationModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, clarification, model]
# @BRIEF Clarification session, question, option, and answer models for guided review flow.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums:Module]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums]
# @RELATION DEPENDS_ON -> [MappingModels]
# @INVARIANT: Only one active clarification question may exist at a time per session.
# @PRE: Database engine initialized
# @POST: Clarification ORM models registered
# @SIDE_EFFECT: Defines dataset review clarification tables
# @DATA_CONTRACT: ClarificationData -> ClarificationRecord
# @INVARIANT Only one active clarification question may exist at a time per session.
# @PRE Database engine initialized
# @POST Clarification ORM models registered
# @SIDE_EFFECT Defines dataset review clarification tables
# @DATA_CONTRACT ClarificationData -> ClarificationRecord
from datetime import datetime
import uuid

View File

@@ -1,7 +1,7 @@
# #region DatasetReviewEnums [C:2] [TYPE Module] [SEMANTICS enum, dataset, review, model, domain]
# @BRIEF All enumeration types for the dataset review domain, grouped for stable cross-module reuse.
# @LAYER: Domain
# @INVARIANT: Enum values are string-based for JSON serialization compatibility.
# @LAYER Domain
# @INVARIANT Enum values are string-based for JSON serialization compatibility.
import enum

View File

@@ -1,7 +1,7 @@
# #region DatasetReviewExecutionModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, execution, model]
# @BRIEF Compiled preview, run context, session event, and export artifact models for execution and audit.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums:Module]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums]
# @RELATION DEPENDS_ON -> [MappingModels]
from datetime import datetime

View File

@@ -1,7 +1,7 @@
# #region DatasetReviewFilterModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, filter, template]
# @BRIEF Imported filter and template variable models for Superset context recovery and execution mapping.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums:Module]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums]
# @RELATION DEPENDS_ON -> [MappingModels]
from datetime import datetime

View File

@@ -1,7 +1,7 @@
# #region DatasetReviewFindingModels [C:2] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, finding, validation]
# @BRIEF Validation finding model for tracking blocking, warning, and informational issues during review.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums:Module]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums]
# @RELATION DEPENDS_ON -> [MappingModels]
from datetime import datetime

View File

@@ -1,7 +1,7 @@
# #region DatasetReviewMappingModels [C:2] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, mapping, model]
# @BRIEF Execution mapping model linking imported filters to template variables with approval gates.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums:Module]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums]
# @RELATION DEPENDS_ON -> [MappingModels]
from datetime import datetime
@@ -30,7 +30,7 @@ from src.models.mapping import Base
# #region ExecutionMapping [C:2] [TYPE Class]
# @BRIEF One filter-to-variable mapping with approval gate, effective value, and transformation metadata.
# @RELATION DEPENDS_ON -> [DatasetReviewSession]
# @INVARIANT: Explicit approval is required before launch when requires_explicit_approval is true.
# @INVARIANT Explicit approval is required before launch when requires_explicit_approval is true.
class ExecutionMapping(Base):
__tablename__ = "execution_mappings"

View File

@@ -1,7 +1,7 @@
# #region DatasetReviewProfileModels [C:2] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, profile, summary]
# @BRIEF Dataset profile model capturing business summary, confidence, and completeness metadata.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums:Module]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums]
# @RELATION DEPENDS_ON -> [MappingModels]
from datetime import datetime

View File

@@ -1,13 +1,13 @@
# #region DatasetReviewSemanticModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, semantic, enrichment]
# @BRIEF Semantic source, field entry, and candidate models for dictionary-driven semantic enrichment.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums:Module]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums]
# @RELATION DEPENDS_ON -> [MappingModels]
# @INVARIANT: Manual overrides are never silently replaced by imported, inferred, or AI-generated values.
# @PRE: Database engine initialized
# @POST: Semantic ORM models registered with override protection
# @SIDE_EFFECT: Defines dataset review semantic tables
# @DATA_CONTRACT: SemanticData -> SemanticFieldEntry
# @INVARIANT Manual overrides are never silently replaced by imported, inferred, or AI-generated values.
# @PRE Database engine initialized
# @POST Semantic ORM models registered with override protection
# @SIDE_EFFECT Defines dataset review semantic tables
# @DATA_CONTRACT SemanticData -> SemanticFieldEntry
from datetime import datetime
import uuid
@@ -70,7 +70,7 @@ class SemanticSource(Base):
# @BRIEF Per-field semantic metadata entry with provenance tracking, lock state, and candidate set.
# @RELATION DEPENDS_ON -> [DatasetReviewSession]
# @RELATION DEPENDS_ON -> [SemanticCandidate]
# @INVARIANT: Locked fields preserve their active value regardless of later candidate proposals.
# @INVARIANT Locked fields preserve their active value regardless of later candidate proposals.
class SemanticFieldEntry(Base):
__tablename__ = "semantic_field_entries"

View File

@@ -1,13 +1,13 @@
# #region DatasetReviewSessionModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, dataset, review, session, model]
# @BRIEF Session aggregate root and collaborator models for dataset review orchestration.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums:Module]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [DatasetReviewEnums]
# @RELATION DEPENDS_ON -> [MappingModels]
# @INVARIANT: Session and profile entities are strictly scoped to an authenticated user.
# @PRE: Database engine initialized
# @POST: Session ORM models registered with optimistic locking
# @SIDE_EFFECT: Defines dataset review session tables
# @DATA_CONTRACT: SessionData -> SessionRecord
# @INVARIANT Session and profile entities are strictly scoped to an authenticated user.
# @PRE Database engine initialized
# @POST Session ORM models registered with optimistic locking
# @SIDE_EFFECT Defines dataset review session tables
# @DATA_CONTRACT SessionData -> SessionRecord
from datetime import datetime
import uuid
@@ -68,7 +68,7 @@ class SessionCollaborator(Base):
# @RELATION DEPENDS_ON -> [DatasetRunContext]
# @RELATION DEPENDS_ON -> [ExportArtifact]
# @RELATION DEPENDS_ON -> [SessionEvent]
# @INVARIANT: Optimistic-lock version column prevents lost-update races on concurrent mutations.
# @INVARIANT Optimistic-lock version column prevents lost-update races on concurrent mutations.
class DatasetReviewSession(Base):
__tablename__ = "dataset_review_sessions"

View File

@@ -1,8 +1,8 @@
# #region FilterStateModels [C:2] [TYPE Module] [SEMANTICS pydantic, filter, model, schema, superset, filter-state]
#
# @BRIEF Pydantic models for Superset native filter state extraction and restoration.
# @LAYER: Models
# @RELATION DEPENDS_ON -> [pydantic]
# @LAYER Domain
# @RELATION DEPENDS_ON -> [EXT:Library:pydantic]
from typing import Any
@@ -11,7 +11,7 @@ from pydantic import BaseModel, ConfigDict, Field
# #region FilterState [C:2] [TYPE Model]
# @BRIEF Represents the state of a single native filter.
# @DATA_CONTRACT: Input[extraFormData: Dict, filterState: Dict, ownState: Optional[Dict]] -> Model[FilterState]
# @DATA_CONTRACT Input[extraFormData: Dict, filterState: Dict, ownState: Optional[Dict]] -> Model[FilterState]
class FilterState(BaseModel):
"""Single native filter state with extraFormData, filterState, and ownState."""
@@ -25,7 +25,7 @@ class FilterState(BaseModel):
# #region NativeFilterDataMask [C:2] [TYPE Model]
# @BRIEF Represents the dataMask containing all native filter states.
# @DATA_CONTRACT: Input[Dict[filter_id, FilterState]] -> Model[NativeFilterDataMask]
# @DATA_CONTRACT Input[Dict[filter_id, FilterState]] -> Model[NativeFilterDataMask]
class NativeFilterDataMask(BaseModel):
"""Container for all native filter states in a dashboard."""
@@ -48,7 +48,7 @@ class NativeFilterDataMask(BaseModel):
# #region ParsedNativeFilters [C:2] [TYPE Model]
# @BRIEF Result of parsing native filters from permalink or native_filters_key.
# @DATA_CONTRACT: Input[dataMask: Dict, metadata: Dict] -> Model[ParsedNativeFilters]
# @DATA_CONTRACT Input[dataMask: Dict, metadata: Dict] -> Model[ParsedNativeFilters]
class ParsedNativeFilters(BaseModel):
"""Result of extracting native filters from a Superset URL."""
@@ -75,7 +75,7 @@ class ParsedNativeFilters(BaseModel):
# #region DashboardURLFilterExtraction [C:2] [TYPE Model]
# @BRIEF Result of parsing a complete dashboard URL for filter information.
# @DATA_CONTRACT: Input[url: str, dashboard_id: Optional, filter_type: Optional, filters: Dict] -> Model[DashboardURLFilterExtraction]
# @DATA_CONTRACT Input[url: str, dashboard_id: Optional, filter_type: Optional, filters: Dict] -> Model[DashboardURLFilterExtraction]
class DashboardURLFilterExtraction(BaseModel):
"""Result of parsing a Superset dashboard URL to extract filter state."""
@@ -92,7 +92,7 @@ class DashboardURLFilterExtraction(BaseModel):
# #region ExtraFormDataMerge [C:2] [TYPE Model]
# @BRIEF Configuration for merging extraFormData from different sources.
# @DATA_CONTRACT: Input[append_keys: List[str], override_keys: List[str]] -> Model[ExtraFormDataMerge]
# @DATA_CONTRACT Input[append_keys: List[str], override_keys: List[str]] -> Model[ExtraFormDataMerge]
class ExtraFormDataMerge(BaseModel):
"""Configuration for merging extraFormData between original and new filter values."""

View File

@@ -1,7 +1,7 @@
# #region LlmModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, llm, model, schema, validate, provider]
# @BRIEF SQLAlchemy models for LLM provider configuration and validation results.
# @LAYER: Domain
# @RELATION INHERITS_FROM -> MappingModels:Base
# @LAYER Domain
# @RELATION INHERITS -> MappingModels:Base
from datetime import datetime
import uuid

View File

@@ -1,8 +1,8 @@
# #region MaintenanceModels [C:2] [TYPE Module] [SEMANTICS sqlalchemy, maintenance, banner, event, settings, model]
# @BRIEF SQLAlchemy models for the Maintenance Banner feature: event, banner, dashboard state, and settings.
# @LAYER Domain
# @RELATION DEPENDS_ON -> [sqlalchemy]
# @RELATION DEPENDS_ON -> [MappingBase]
# @RELATION DEPENDS_ON -> [EXT:Library:sqlalchemy]
# @RELATION DEPENDS_ON -> [EXT:internal:MappingBase]
# @INVARIANT MaintenanceDashboardBanner has unique partial index on (environment_id, dashboard_id) WHERE status='active'
# @INVARIANT MaintenanceSettings is a singleton row (id='default') enforced by CheckConstraint

View File

@@ -1,16 +1,16 @@
# #region MappingModels [C:5] [TYPE Module] [SEMANTICS sqlalchemy, mapping, model, schema, resource-type]
#
# @BRIEF Defines the database schema for environment metadata and database mappings using SQLAlchemy.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> sqlalchemy
# @LAYER Domain
# @RELATION DEPENDS_ON -> [EXT:Library:sqlalchemy]
#
# @INVARIANT: All primary keys are UUID strings.
# @INVARIANT All primary keys are UUID strings.
# CONSTRAINT: source_env_id and target_env_id must be valid environment IDs.
# @PRE: Database engine initialized
# @POST: Mapping ORM models registered with UUID primary keys
# @SIDE_EFFECT: Defines environment/database/resource mapping tables
# @DATA_CONTRACT: MappingData -> MappingRecord
# @PRE Database engine initialized
# @POST Mapping ORM models registered with UUID primary keys
# @SIDE_EFFECT Defines environment/database/resource mapping tables
# @DATA_CONTRACT MappingData -> MappingRecord
import enum
import uuid

View File

@@ -1,16 +1,16 @@
# #region ProfileModels [C:5] [TYPE Module] [SEMANTICS sqlalchemy, profile, model, schema, git, dashboard]
#
# @BRIEF Defines persistent per-user profile settings for dashboard filter, Git identity/token, and UX preferences.
# @LAYER: Domain
# @LAYER Domain
# @RELATION DEPENDS_ON -> [AuthModels]
# @RELATION INHERITS_FROM -> [MappingModels:Base]
# @RELATION INHERITS -> [EXT:internal:MappingModels:Base]
#
# @INVARIANT: Exactly one preference row exists per user_id.
# @INVARIANT: Sensitive Git token is stored encrypted and never returned in plaintext.
# @PRE: Database engine initialized
# @POST: Profile ORM models registered
# @SIDE_EFFECT: Defines user profile/preference tables
# @DATA_CONTRACT: ProfileData -> PreferenceRecord
# @INVARIANT Exactly one preference row exists per user_id.
# @INVARIANT Sensitive Git token is stored encrypted and never returned in plaintext.
# @PRE Database engine initialized
# @POST Profile ORM models registered
# @SIDE_EFFECT Defines user profile/preference tables
# @DATA_CONTRACT ProfileData -> PreferenceRecord
from datetime import datetime
import uuid

View File

@@ -1,12 +1,12 @@
# #region ReportModels [C:3] [TYPE Module] [SEMANTICS pydantic, report, model, schema, task, task-type]
# @BRIEF Canonical report schemas for unified task reporting across heterogeneous task types.
# @LAYER: Domain
# @PRE: Pydantic library and task manager models are available.
# @POST: Provides validated schemas for cross-plugin reporting and UI consumption.
# @SIDE_EFFECT: None (schema definition).
# @DATA_CONTRACT: Model[TaskReport, ReportCollection, ReportDetailView]
# @LAYER Domain
# @PRE Pydantic library and task manager models are available.
# @POST Provides validated schemas for cross-plugin reporting and UI consumption.
# @SIDE_EFFECT None (schema definition).
# @DATA_CONTRACT Model[TaskReport, ReportCollection, ReportDetailView]
# @RELATION DEPENDS_ON -> [TaskModels]
# @INVARIANT: Canonical report fields are always present for every report item.
# @INVARIANT Canonical report fields are always present for every report item.
from datetime import datetime
from enum import Enum
@@ -16,7 +16,7 @@ from pydantic import BaseModel, Field, field_validator, model_validator
# #region TaskType [C:3] [TYPE Class] [SEMANTICS enum, type, task]
# @INVARIANT: Must contain valid generic task type mappings.
# @INVARIANT Must contain valid generic task type mappings.
# @RELATION DEPENDS_ON -> ReportModels
# @BRIEF Supported normalized task report types.
class TaskType(str, Enum):
@@ -32,7 +32,7 @@ class TaskType(str, Enum):
# #region ReportStatus [C:3] [TYPE Class] [SEMANTICS enum, status, task]
# @INVARIANT: TaskStatus enum mapping logic holds.
# @INVARIANT TaskStatus enum mapping logic holds.
# @BRIEF Supported normalized report status values.
# @RELATION DEPENDS_ON -> ReportModels
class ReportStatus(str, Enum):
@@ -46,10 +46,10 @@ class ReportStatus(str, Enum):
# #region ErrorContext [C:3] [TYPE Class] [SEMANTICS error, context, payload]
# @INVARIANT: The properties accurately describe error state.
# @INVARIANT The properties accurately describe error state.
# @BRIEF Error and recovery context for failed/partial reports.
#
# @TEST_CONTRACT: ErrorContextModel ->
# @TEST_CONTRACT ErrorContextModel ->
# {
# required_fields: {
# message: str
@@ -59,8 +59,8 @@ class ReportStatus(str, Enum):
# next_actions: list[str]
# }
# }
# @TEST_FIXTURE: basic_error -> {"message": "Connection timeout", "code": "ERR_504", "next_actions": ["retry"]}
# @TEST_EDGE: missing_message -> {"code": "ERR_504"}
# @TEST_FIXTURE basic_error -> {"message": "Connection timeout", "code": "ERR_504", "next_actions": ["retry"]}
# @TEST_EDGE missing_message -> {"code": "ERR_504"}
# @RELATION DEPENDS_ON -> ReportModels
class ErrorContext(BaseModel):
code: str | None = None
@@ -72,10 +72,10 @@ class ErrorContext(BaseModel):
# #region TaskReport [C:3] [TYPE Class] [SEMANTICS report, model, summary]
# @INVARIANT: Must represent canonical task record attributes.
# @INVARIANT Must represent canonical task record attributes.
# @BRIEF Canonical normalized report envelope for one task execution.
#
# @TEST_CONTRACT: TaskReportModel ->
# @TEST_CONTRACT TaskReportModel ->
# {
# required_fields: {
# report_id: str,
@@ -91,7 +91,7 @@ class ErrorContext(BaseModel):
# "summary is a non-empty string"
# ]
# }
# @TEST_FIXTURE: valid_task_report ->
# @TEST_FIXTURE valid_task_report ->
# {
# report_id: "rep-123",
# task_id: "task-456",
@@ -100,10 +100,10 @@ class ErrorContext(BaseModel):
# updated_at: "2026-02-26T12:00:00Z",
# summary: "Migration completed successfully"
# }
# @TEST_EDGE: empty_report_id -> {"report_id": " ", "task_id": "task-456", "task_type": "migration", "status": "success", "updated_at": "2026-02-26T12:00:00Z", "summary": "Done"}
# @TEST_EDGE: empty_summary -> {"report_id": "rep-123", "task_id": "task-456", "task_type": "migration", "status": "success", "updated_at": "2026-02-26T12:00:00Z", "summary": ""}
# @TEST_EDGE: invalid_task_type -> {"report_id": "rep-123", "task_id": "task-456", "task_type": "invalid_type", "status": "success", "updated_at": "2026-02-26T12:00:00Z", "summary": "Done"}
# @TEST_INVARIANT: non_empty_validators -> verifies: [empty_report_id, empty_summary]
# @TEST_EDGE empty_report_id -> {"report_id": " ", "task_id": "task-456", "task_type": "migration", "status": "success", "updated_at": "2026-02-26T12:00:00Z", "summary": "Done"}
# @TEST_EDGE empty_summary -> {"report_id": "rep-123", "task_id": "task-456", "task_type": "migration", "status": "success", "updated_at": "2026-02-26T12:00:00Z", "summary": ""}
# @TEST_EDGE invalid_task_type -> {"report_id": "rep-123", "task_id": "task-456", "task_type": "invalid_type", "status": "success", "updated_at": "2026-02-26T12:00:00Z", "summary": "Done"}
# @TEST_INVARIANT non_empty_validators -> verifies: [empty_report_id, empty_summary]
# @RELATION DEPENDS_ON -> ReportModels
class TaskReport(BaseModel):
report_id: str
@@ -130,10 +130,10 @@ class TaskReport(BaseModel):
# #region ReportQuery [C:3] [TYPE Class] [SEMANTICS query, filter, search]
# @INVARIANT: Time and pagination queries are mutually consistent.
# @INVARIANT Time and pagination queries are mutually consistent.
# @BRIEF Query object for server-side report filtering, sorting, and pagination.
#
# @TEST_CONTRACT: ReportQueryModel ->
# @TEST_CONTRACT ReportQueryModel ->
# {
# optional_fields: {
# page: int, page_size: int, task_types: list[TaskType], statuses: list[ReportStatus],
@@ -146,11 +146,11 @@ class TaskReport(BaseModel):
# "time_from <= time_to if both exist"
# ]
# }
# @TEST_FIXTURE: valid_query -> {"page": 1, "page_size":20, "sort_by": "updated_at", "sort_order": "desc"}
# @TEST_EDGE: invalid_page_size_large -> {"page_size": 150}
# @TEST_EDGE: invalid_sort_by -> {"sort_by": "unknown_field"}
# @TEST_EDGE: invalid_time_range -> {"time_from": "2026-02-26T12:00:00Z", "time_to": "2026-02-25T12:00:00Z"}
# @TEST_INVARIANT: attribute_constraints_enforced -> verifies: [invalid_page_size_large, invalid_sort_by, invalid_time_range]
# @TEST_FIXTURE valid_query -> {"page": 1, "page_size":20, "sort_by": "updated_at", "sort_order": "desc"}
# @TEST_EDGE invalid_page_size_large -> {"page_size": 150}
# @TEST_EDGE invalid_sort_by -> {"sort_by": "unknown_field"}
# @TEST_EDGE invalid_time_range -> {"time_from": "2026-02-26T12:00:00Z", "time_to": "2026-02-25T12:00:00Z"}
# @TEST_INVARIANT attribute_constraints_enforced -> verifies: [invalid_page_size_large, invalid_sort_by, invalid_time_range]
# @RELATION DEPENDS_ON -> ReportModels
class ReportQuery(BaseModel):
page: int = Field(default=1, ge=1)
@@ -189,18 +189,18 @@ class ReportQuery(BaseModel):
# #region ReportCollection [C:3] [TYPE Class] [SEMANTICS collection, pagination]
# @INVARIANT: Represents paginated data correctly.
# @INVARIANT Represents paginated data correctly.
# @BRIEF Paginated collection of normalized task reports.
#
# @TEST_CONTRACT: ReportCollectionModel ->
# @TEST_CONTRACT ReportCollectionModel ->
# {
# required_fields: {
# items: list[TaskReport], total: int, page: int, page_size: int, has_next: bool, applied_filters: ReportQuery
# },
# invariants: ["total >= 0", "page >= 1", "page_size >= 1"]
# }
# @TEST_FIXTURE: empty_collection -> {"items": [], "total": 0, "page": 1, "page_size": 20, "has_next": False, "applied_filters": {}}
# @TEST_EDGE: negative_total -> {"items": [], "total": -5, "page": 1, "page_size": 20, "has_next": False, "applied_filters": {}}
# @TEST_FIXTURE empty_collection -> {"items": [], "total": 0, "page": 1, "page_size": 20, "has_next": False, "applied_filters": {}}
# @TEST_EDGE negative_total -> {"items": [], "total": -5, "page": 1, "page_size": 20, "has_next": False, "applied_filters": {}}
# @RELATION DEPENDS_ON -> ReportModels
class ReportCollection(BaseModel):
items: list[TaskReport]
@@ -215,16 +215,16 @@ class ReportCollection(BaseModel):
# #region ReportDetailView [C:3] [TYPE Class] [SEMANTICS view, detail, logs]
# @INVARIANT: Incorporates a report and logs correctly.
# @INVARIANT Incorporates a report and logs correctly.
# @BRIEF Detailed report representation including diagnostics and recovery actions.
#
# @TEST_CONTRACT: ReportDetailViewModel ->
# @TEST_CONTRACT ReportDetailViewModel ->
# {
# required_fields: {report: TaskReport},
# optional_fields: {timeline: list[dict], diagnostics: dict, next_actions: list[str]}
# }
# @TEST_FIXTURE: valid_detail -> {"report": {"report_id": "rep-1", "task_id": "task-1", "task_type": "backup", "status": "success", "updated_at": "2026-02-26T12:00:00Z", "summary": "Done"}}
# @TEST_EDGE: missing_report -> {}
# @TEST_FIXTURE valid_detail -> {"report": {"report_id": "rep-1", "task_id": "task-1", "task_type": "backup", "status": "success", "updated_at": "2026-02-26T12:00:00Z", "summary": "Done"}}
# @TEST_EDGE missing_report -> {}
# @RELATION DEPENDS_ON -> ReportModels
class ReportDetailView(BaseModel):
report: TaskReport

View File

@@ -1,10 +1,10 @@
# #region TaskModels [C:1] [TYPE Module] [SEMANTICS sqlalchemy, task, model, schema, execution, task-record]
#
# @BRIEF Defines the database schema for task execution records.
# @LAYER: Domain
# @RELATION DEPENDS_ON -> sqlalchemy
# @LAYER Domain
# @RELATION DEPENDS_ON -> [EXT:Library:sqlalchemy]
#
# @INVARIANT: All primary keys are UUID strings.
# @INVARIANT All primary keys are UUID strings.
import uuid
@@ -35,9 +35,9 @@ class TaskRecord(Base):
# #region TaskLogRecord [C:3] [TYPE Class]
# @BRIEF Represents a single persistent log entry for a task.
# @RELATION DEPENDS_ON -> TaskRecord
# @INVARIANT: Each log entry belongs to exactly one task.
# @INVARIANT Each log entry belongs to exactly one task.
#
# @TEST_CONTRACT: TaskLogCreate ->
# @TEST_CONTRACT TaskLogCreate ->
# {
# required_fields: {
# task_id: str,
@@ -55,7 +55,7 @@ class TaskRecord(Base):
# ]
# }
#
# @TEST_FIXTURE: basic_info_log ->
# @TEST_FIXTURE basic_info_log ->
# {
# task_id: "00000000-0000-0000-0000-000000000000",
# timestamp: "2026-02-26T12:00:00Z",
@@ -64,7 +64,7 @@ class TaskRecord(Base):
# message: "Task initialization complete"
# }
#
# @TEST_EDGE: missing_required_field ->
# @TEST_EDGE missing_required_field ->
# {
# timestamp: "2026-02-26T12:00:00Z",
# level: "ERROR",
@@ -72,7 +72,7 @@ class TaskRecord(Base):
# message: "Missing task_id"
# }
#
# @TEST_EDGE: invalid_type ->
# @TEST_EDGE invalid_type ->
# {
# task_id: "00000000-0000-0000-0000-000000000000",
# timestamp: "2026-02-26T12:00:00Z",
@@ -81,7 +81,7 @@ class TaskRecord(Base):
# message: "Integer level"
# }
#
# @TEST_EDGE: empty_message ->
# @TEST_EDGE empty_message ->
# {
# task_id: "00000000-0000-0000-0000-000000000000",
# timestamp: "2026-02-26T12:00:00Z",
@@ -90,7 +90,7 @@ class TaskRecord(Base):
# message: ""
# }
#
# @TEST_INVARIANT: exact_one_task_association -> verifies: [basic_info_log, missing_required_field]
# @TEST_INVARIANT exact_one_task_association -> verifies: [basic_info_log, missing_required_field]
class TaskLogRecord(Base):
__tablename__ = "task_logs"

View File

@@ -1,6 +1,6 @@
# #region TranslateModels [C:3] [TYPE Module] [SEMANTICS sqlalchemy, translate, model, schema, dashboard, llm]
# @BRIEF SQLAlchemy ORM models for LLM-based SQL/dashboard translation across dialects.
# @LAYER: Domain
# @LAYER Domain
# @RELATION INHERITS -> [MappingModels]
from datetime import UTC, datetime
@@ -18,8 +18,8 @@ def generate_uuid():
# #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.
# @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"