Core changes: - Add @defgroup/@ingroup to 1791 C2+ contracts (555 files) for HCA 128× pre-training DSA grouping - Add §0.1 Pre-Training Frequency matrix to semantics-core - Add §VIII Attention Architecture rules (ATTN_1-4) with MLA/CSA/HCA/DSA mechanics - Add @defgroup/@ingroup to canonical syntax (§II) and all contract examples Agent prompts (5 files): - Add ZERO-STATE RATIONALE with MLA/CSA/HCA/DSA compression mechanics - Add pre-training note: @RATIONALE/@REJECTED are in-context learned tags - svelte-coder: add missing #region contract, fix Svelte rule violations - python-coder/fullstack-coder: honor function contracts from speckit plan - qa-tester: add attention compliance audit (P3 ATTN_1-4 checks) Skills (6 files): - Translate all axiom_config descriptions to English - Fix doc_dirs to index .opencode/ and .specify/ - Deduplicate 5× complexity_rules → single global_tags catalog - Reduce semantics-svelte 591→485 lines (remove duplicate code blocks) - Fix semantics-testing: 'Short IDs' → 'Short hierarchical IDs' - Fix all examples: flat IDs → hierarchical Domain.Name format - Fix Svelte examples: replace raw Tailwind + <button> with semantic tokens + /ui Speckit workflow (commands + templates): - speckit.plan: add Function-Level Contracts for C3+ with @PRE/@POST/@TEST_EDGE - speckit.plan: add Attention Compliance Gate (ATTN_1-4 before contract generation) - speckit.tasks: add function contract inlining format (constraints in task description) - speckit.specify: load semantics-core for spec density rules - spec-template: add #region contract, @SEMANTICS grouping, hierarchical IDs - ux-reference-template: add #region wrapper - plan-template: add attention gate, @defgroup/@ingroup guidance - tasks-template: add attention audit + rebuild + orphan check tasks - constitution.md: translate to English, add Principle VIII (attention-optimized contracts) Reference modules rewritten (hierarchical IDs + full contracts): - Auth.Jwt: 6 child contracts with @RATIONALE/@REJECTED/@TEST_EDGE - Api.Auth: 5 endpoints with @TEST_EDGE + molecular CoT markers - Migration.Model: @defgroup Migration with 18 @ACTION + 6 @INVARIANT Scripts: - add_defgroup_ingroup.py: zero-risk additive @ingroup migration (1791 insertions) - migrate_hierarchical.py: flat→hierarchical ID dry-run analysis (792 contracts) - merge_prompts.py: merge all prompts/skills/commands into one review file Config: - axiom_config.yaml: 749→395 lines (-47%), English, doc_dirs include prompts - Fix test_datasets.py import collision (rename → test_datasets_routes.py) - Fix test_preview.py: SupersetClient→get_superset_client, AsyncMock, logger f-string
115 lines
3.7 KiB
Python
115 lines
3.7 KiB
Python
# #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 -> [EXT:Library:sqlalchemy]
|
|
#
|
|
# @INVARIANT All primary keys are UUID strings.
|
|
|
|
import uuid
|
|
|
|
from sqlalchemy import JSON, Column, DateTime, ForeignKey, Index, Integer, String, Text
|
|
from sqlalchemy.sql import func
|
|
|
|
from .mapping import Base
|
|
|
|
|
|
# #region TaskRecord [C:1] [TYPE Class]
|
|
# @BRIEF Represents a persistent record of a task execution.
|
|
class TaskRecord(Base):
|
|
__tablename__ = "task_records"
|
|
|
|
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
type = Column(String, nullable=False) # e.g., "backup", "migration"
|
|
status = Column(String, nullable=False) # Enum: "PENDING", "RUNNING", "SUCCESS", "FAILED"
|
|
environment_id = Column(String, ForeignKey("environments.id", ondelete="SET NULL"), nullable=True)
|
|
started_at = Column(DateTime(timezone=True), nullable=True)
|
|
finished_at = Column(DateTime(timezone=True), nullable=True)
|
|
logs = Column(JSON, nullable=True) # Store structured logs as JSON (legacy, kept for backward compatibility)
|
|
error = Column(String, nullable=True)
|
|
result = Column(JSON, nullable=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
params = Column(JSON, nullable=True)
|
|
# #endregion TaskRecord
|
|
|
|
# #region TaskLogRecord [C:3] [TYPE Class]
|
|
# @defgroup Models Module group.
|
|
# @BRIEF Represents a single persistent log entry for a task.
|
|
# @RELATION DEPENDS_ON -> TaskRecord
|
|
# @INVARIANT Each log entry belongs to exactly one task.
|
|
#
|
|
# @TEST_CONTRACT TaskLogCreate ->
|
|
# {
|
|
# required_fields: {
|
|
# task_id: str,
|
|
# timestamp: datetime,
|
|
# level: str,
|
|
# source: str,
|
|
# message: str
|
|
# },
|
|
# optional_fields: {
|
|
# metadata_json: str,
|
|
# id: int
|
|
# },
|
|
# invariants: [
|
|
# "task_id matches an existing TaskRecord.id"
|
|
# ]
|
|
# }
|
|
#
|
|
# @TEST_FIXTURE basic_info_log ->
|
|
# {
|
|
# task_id: "00000000-0000-0000-0000-000000000000",
|
|
# timestamp: "2026-02-26T12:00:00Z",
|
|
# level: "INFO",
|
|
# source: "system",
|
|
# message: "Task initialization complete"
|
|
# }
|
|
#
|
|
# @TEST_EDGE missing_required_field ->
|
|
# {
|
|
# timestamp: "2026-02-26T12:00:00Z",
|
|
# level: "ERROR",
|
|
# source: "system",
|
|
# message: "Missing task_id"
|
|
# }
|
|
#
|
|
# @TEST_EDGE invalid_type ->
|
|
# {
|
|
# task_id: "00000000-0000-0000-0000-000000000000",
|
|
# timestamp: "2026-02-26T12:00:00Z",
|
|
# level: 500,
|
|
# source: "system",
|
|
# message: "Integer level"
|
|
# }
|
|
#
|
|
# @TEST_EDGE empty_message ->
|
|
# {
|
|
# task_id: "00000000-0000-0000-0000-000000000000",
|
|
# timestamp: "2026-02-26T12:00:00Z",
|
|
# level: "DEBUG",
|
|
# source: "system",
|
|
# message: ""
|
|
# }
|
|
#
|
|
# @TEST_INVARIANT exact_one_task_association -> verifies: [basic_info_log, missing_required_field]
|
|
class TaskLogRecord(Base):
|
|
__tablename__ = "task_logs"
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
task_id = Column(String, ForeignKey("task_records.id", ondelete="CASCADE"), nullable=False, index=True)
|
|
timestamp = Column(DateTime(timezone=True), nullable=False, index=True)
|
|
level = Column(String(16), nullable=False) # INFO, WARNING, ERROR, DEBUG
|
|
source = Column(String(64), nullable=False, default="system") # plugin, superset_api, git, etc.
|
|
message = Column(Text, nullable=False)
|
|
metadata_json = Column(Text, nullable=True) # JSON string for additional metadata
|
|
|
|
# Composite indexes for efficient filtering
|
|
__table_args__ = (
|
|
Index('ix_task_logs_task_timestamp', 'task_id', 'timestamp'),
|
|
Index('ix_task_logs_task_level', 'task_id', 'level'),
|
|
Index('ix_task_logs_task_source', 'task_id', 'source'),
|
|
)
|
|
# #endregion TaskLogRecord
|
|
|
|
# #endregion TaskModels
|