常见故障自愈有上限,超限收敛终态且可见:任务 attempts 上限、会话过期、 planning 双闸、executing 超窗兜底、触发失败计数判死、孤儿 agent 双管、 fire-and-forget 触发;open_session 预算硬闸门、settle 按终态区分、报告 scores 归一化;cron 池遗留面全删。
46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
"""add alert history table
|
||
|
||
Revision ID: c8f3e9a2b4d1
|
||
Revises: b72debf55c3b
|
||
Create Date: 2026-08-12 10:00:00.000000
|
||
|
||
"""
|
||
from typing import Sequence, Union
|
||
|
||
from alembic import op
|
||
import sqlalchemy as sa
|
||
import sqlmodel
|
||
|
||
|
||
# revision identifiers, used by Alembic.
|
||
revision: str = 'c8f3e9a2b4d1'
|
||
down_revision: Union[str, Sequence[str], None] = 'b72debf55c3b'
|
||
branch_labels: Union[str, Sequence[str], None] = None
|
||
depends_on: Union[str, Sequence[str], None] = None
|
||
|
||
|
||
def upgrade() -> None:
|
||
"""Upgrade schema."""
|
||
op.create_table(
|
||
'cron_pool_alert_history',
|
||
sa.Column('id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||
sa.Column('alert_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||
sa.Column('severity', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||
sa.Column('message', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||
sa.Column('metric_value', sa.Float(), nullable=False),
|
||
sa.Column('threshold', sa.Float(), nullable=False),
|
||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||
sa.Column('resolved_at', sa.DateTime(), nullable=True),
|
||
sa.Column('webhook_sent', sa.Boolean(), nullable=False, default=False),
|
||
sa.PrimaryKeyConstraint('id')
|
||
)
|
||
with op.batch_alter_table('cron_pool_alert_history', schema=None) as batch_op:
|
||
batch_op.create_index('ix_cron_pool_alert_history_alert_type', ['alert_type'], unique=False)
|
||
batch_op.create_index('ix_cron_pool_alert_history_severity', ['severity'], unique=False)
|
||
|
||
|
||
def downgrade() -> None:
|
||
"""Downgrade schema."""
|
||
# 表已随 cron 池清理从 create_all 移除(ADR-0011 Phase 4),downgrade 容错缺失
|
||
op.execute("DROP TABLE IF EXISTS cron_pool_alert_history")
|