Files
ss-tools/backend/src/models/config.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

52 lines
2.6 KiB
Python

# #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
# @RELATION DEPENDS_ON -> [MappingModels]
# @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
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.
class AppConfigRecord(Base):
__tablename__ = "app_configurations"
id = Column(String, primary_key=True)
payload = Column(JSON, nullable=False)
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
# #endregion AppConfigRecord
# #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.
class NotificationConfig(Base):
__tablename__ = "notification_configs"
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
type = Column(String, nullable=False) # SMTP, SLACK, TELEGRAM
name = Column(String, nullable=False)
credentials = Column(JSON, nullable=False) # Encrypted connection details
is_active = Column(Boolean, default=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
# #endregion NotificationConfig
import uuid
# #endregion ConfigModels