mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
Re-apply the trim style after the prior refactor commit re-introduced a multi-line docstring on AutomationRun. - AutomationRun: drop the four-line docstring explaining where per-step session ids live; move the note to a single-line inline comment right above ``step_results`` where it's actionable. - AutomationDefinition: drop the design-plan cross-reference; the module docstring already establishes what the file is. No behaviour change.
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""``automation_runs`` table — immutable per-fire execution record."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from sqlalchemy import (
|
|
TIMESTAMP,
|
|
Column,
|
|
Enum as SQLAlchemyEnum,
|
|
ForeignKey,
|
|
Integer,
|
|
)
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
|
|
from app.db import BaseModel, TimestampMixin
|
|
|
|
from ..enums.run_status import RunStatus
|
|
|
|
|
|
class AutomationRun(BaseModel, TimestampMixin):
|
|
__tablename__ = "automation_runs"
|
|
|
|
automation_id = Column(
|
|
Integer,
|
|
ForeignKey("automations.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
|
|
trigger_id = Column(
|
|
Integer,
|
|
ForeignKey("automation_triggers.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
index=True,
|
|
)
|
|
|
|
status = Column(
|
|
SQLAlchemyEnum(RunStatus, name="automation_run_status"),
|
|
nullable=False,
|
|
default=RunStatus.PENDING,
|
|
server_default=RunStatus.PENDING.value,
|
|
index=True,
|
|
)
|
|
|
|
# locked at fire time so historical runs always show the exact code path
|
|
definition_snapshot = Column(JSONB, nullable=False)
|
|
|
|
trigger_payload = Column(JSONB, nullable=True)
|
|
resolved_inputs = Column(JSONB, nullable=False, server_default="{}")
|
|
# one entry per executed step; agent_task entries carry their own
|
|
# `agent_session_id` (LangGraph thread reference) inside this JSONB
|
|
step_results = Column(JSONB, nullable=False, server_default="[]")
|
|
output = Column(JSONB, nullable=True)
|
|
artifacts = Column(JSONB, nullable=False, server_default="[]")
|
|
error = Column(JSONB, nullable=True)
|
|
|
|
started_at = Column(TIMESTAMP(timezone=True), nullable=True)
|
|
finished_at = Column(TIMESTAMP(timezone=True), nullable=True)
|