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)
74 lines
3.1 KiB
Python
74 lines
3.1 KiB
Python
# #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 -> [MappingModels]
|
|
|
|
from datetime import datetime
|
|
import uuid
|
|
|
|
from sqlalchemy import JSON, Boolean, Column, DateTime, String, Text, Time
|
|
|
|
from .mapping import Base
|
|
|
|
|
|
def generate_uuid():
|
|
return str(uuid.uuid4())
|
|
|
|
# #region ValidationPolicy [TYPE Class]
|
|
# @BRIEF Defines a scheduled rule for validating a group of dashboards within an execution window.
|
|
# @RELATION DEPENDS_ON -> [LLMProvider]
|
|
class ValidationPolicy(Base):
|
|
__tablename__ = "validation_policies"
|
|
|
|
id = Column(String, primary_key=True, default=generate_uuid)
|
|
name = Column(String, nullable=False)
|
|
environment_id = Column(String, nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
dashboard_ids = Column(JSON, nullable=False) # Array of dashboard IDs
|
|
provider_id = Column(String, nullable=True) # Reference to LLMProvider.id
|
|
schedule_days = Column(JSON, nullable=False) # Array of integers (0-6)
|
|
window_start = Column(Time, nullable=False)
|
|
window_end = Column(Time, nullable=False)
|
|
notify_owners = Column(Boolean, default=True)
|
|
custom_channels = Column(JSON, nullable=True) # List of external channels
|
|
alert_condition = Column(String, default="FAIL_ONLY") # FAIL_ONLY, WARN_AND_FAIL, ALWAYS
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
# #endregion ValidationPolicy
|
|
|
|
# #region LLMProvider [TYPE Class]
|
|
# @BRIEF SQLAlchemy model for LLM provider configuration.
|
|
class LLMProvider(Base):
|
|
__tablename__ = "llm_providers"
|
|
|
|
id = Column(String, primary_key=True, default=generate_uuid)
|
|
provider_type = Column(String, nullable=False) # openai, openrouter, kilo
|
|
name = Column(String, nullable=False)
|
|
base_url = Column(String, nullable=False)
|
|
api_key = Column(String, nullable=False) # Should be encrypted
|
|
default_model = Column(String, nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
is_multimodal = Column(Boolean, default=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
# #endregion LLMProvider
|
|
|
|
# #region ValidationRecord [TYPE Class]
|
|
# @BRIEF SQLAlchemy model for dashboard validation history.
|
|
class ValidationRecord(Base):
|
|
__tablename__ = "llm_validation_results"
|
|
|
|
id = Column(String, primary_key=True, default=generate_uuid)
|
|
task_id = Column(String, nullable=True, index=True) # Reference to TaskRecord
|
|
policy_id = Column(String, nullable=True, index=True) # Reference to ValidationPolicy.id
|
|
dashboard_id = Column(String, nullable=False, index=True)
|
|
environment_id = Column(String, nullable=True, index=True)
|
|
timestamp = Column(DateTime, default=datetime.utcnow)
|
|
status = Column(String, nullable=False) # PASS, WARN, FAIL, UNKNOWN
|
|
screenshot_path = Column(String, nullable=True)
|
|
issues = Column(JSON, nullable=False)
|
|
summary = Column(Text, nullable=False)
|
|
raw_response = Column(Text, nullable=True)
|
|
# #endregion ValidationRecord
|
|
|
|
# #endregion LlmModels
|