Files
2026-08-21 16:00:13 +08:00

39 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""大周天运行记录(architecture §3.2;v1-scope §3.3)。
大周天是长期演化循环:记忆积累 → 自我评估 → 演化策略 → 候选生成。
本表记录每次循环的触发、阶段与终态;演化候选 / 内驱力 / 自动抽取由后续
子阶段写入各自表,循环本身只承载编排与留痕。
"""
from datetime import datetime
from sqlalchemy import DateTime, ForeignKey, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.core.ids import new_cycle_id
from app.core.time import utc_now
from app.db.base import Base
class BigCycle(Base):
"""大周天循环运行记录。"""
__tablename__ = "big_cycles"
id: Mapped[str] = mapped_column(String(80), primary_key=True, default=new_cycle_id)
character_id: Mapped[str] = mapped_column(String(80), ForeignKey("characters.id"), index=True)
trigger: Mapped[str] = mapped_column(String(40), nullable=False)
status: Mapped[str] = mapped_column(String(40), nullable=False, default="pending", index=True)
phase: Mapped[str | None] = mapped_column(String(40))
memory_count_at_trigger: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
evaluation_snapshot_json: Mapped[str | None] = mapped_column(Text)
summary: Mapped[str | None] = mapped_column(Text)
error_code: Mapped[str | None] = mapped_column(String(80))
error_message: Mapped[str | None] = mapped_column(Text)
started_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True))
completed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), index=True)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=utc_now)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), default=utc_now, onupdate=utc_now
)