Files
ss-tools/backend/src/models/profile.py
busya f49b7d909e feat: GRACE-Poly protocol optimization — ~3200→10 warnings (↓99.7%)
Full optimization cycle:

Protocol (15 files):
- 4-layer SSOT architecture for agent prompts & skills
- Anti-Corruption Protocol consolidated from 5 duplicates
- Tag-to-tier permissiveness matrix (all @tags allowed at all tiers)

Axiom config:
- complexity_rules: all 22+ tags available on C1-C5
- contract_type_overrides: removed (was narrowing per-type)
- 18 new tags added, LAYER enum expanded (Infra, Frontend, Atom, etc.)
- RELATION predicates expanded (USES, CONTAINS, BELONGS_TO, etc.)

Code fixes:
- 2216 @TAG: normalized to @TAG (colon→space)
- 518 [DEF] blocks migrated to #region/#endregion (37 files)
- VERIFIES→BINDS_TO, :Class/:Function suffixes removed, paths→IDs
- 1173-line _external_stubs.py deleted (EXT: handled natively)
- Batch EXT: reference audit (240 targets: 132 external, 99 internal, 9 fix)
- QA regression check: 0 regressions across all checks

Infrastructure:
- DuckDB rebuild stabilized (appender API, INSERT OR IGNORE)
- Anchor regex fix (parent-child BINDS_TO now resolves)
- EXT:*/DTO:/NEED_CONTEXT: regex fixed in validator
- 34MB Doxygen API portal (3194 contract pages)
2026-05-26 11:14:25 +03:00

63 lines
2.4 KiB
Python

# #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
# @RELATION DEPENDS_ON -> [AuthModels]
# @RELATION INHERITS -> [MappingModels]
#
# @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
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, String
from sqlalchemy.orm import relationship
from .mapping import Base
# #region UserDashboardPreference [C:3] [TYPE Class]
# @BRIEF Stores Superset username binding and default "my dashboards" toggle for one authenticated user.
# @RELATION INHERITS -> [MappingModels]
class UserDashboardPreference(Base):
__tablename__ = "user_dashboard_preferences"
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
user_id = Column(String, ForeignKey("users.id"), nullable=False, unique=True, index=True)
superset_username = Column(String, nullable=True)
superset_username_normalized = Column(String, nullable=True, index=True)
show_only_my_dashboards = Column(Boolean, nullable=False, default=False)
show_only_slug_dashboards = Column(Boolean, nullable=False, default=True)
git_username = Column(String, nullable=True)
git_email = Column(String, nullable=True)
git_personal_access_token_encrypted = Column(String, nullable=True)
start_page = Column(String, nullable=False, default="dashboards")
auto_open_task_drawer = Column(Boolean, nullable=False, default=True)
dashboards_table_density = Column(String, nullable=False, default="comfortable")
telegram_id = Column(String, nullable=True)
email_address = Column(String, nullable=True)
notify_on_fail = Column(Boolean, nullable=False, default=True)
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
updated_at = Column(
DateTime,
nullable=False,
default=datetime.utcnow,
onupdate=datetime.utcnow,
)
user = relationship("User")
# #endregion UserDashboardPreference
# #endregion ProfileModels