feat: 任务中心升级(失败重试/错误追踪/列表筛选) #289

Merged
xiaoxia merged 6 commits from feat/task-center-upgrade into develop 2026-07-14 09:55:53 +08:00
Owner

任务中心升级

完成内容

  1. 失败重试 — 失败任务支持手动重试,原地重试复用同一个task_id
  2. 错误追踪 — error_info结构化存储(error_type/message/stack_trace/stage/failed_at)
  3. 列表筛选 — 按状态、任务类型筛选,分页返回
  4. 自动重试配置 — 指数退避(5s→10s→20s→40s→60s封顶),最多5次,默认关闭
  5. retry_count字段 — 记录重试次数

关键设计

  • 原地重试:复用同一个task_id,保留历史关联,retry_count+1
  • error_info存JSON:结构化存储便于查询和展示
  • 自动重试默认关闭:指数退避防雪崩

测试

  • 51个状态相关测试全部通过
  • 无回归
## 任务中心升级 ### 完成内容 1. **失败重试** — 失败任务支持手动重试,原地重试复用同一个task_id 2. **错误追踪** — error_info结构化存储(error_type/message/stack_trace/stage/failed_at) 3. **列表筛选** — 按状态、任务类型筛选,分页返回 4. **自动重试配置** — 指数退避(5s→10s→20s→40s→60s封顶),最多5次,默认关闭 5. **retry_count字段** — 记录重试次数 ### 关键设计 - 原地重试:复用同一个task_id,保留历史关联,retry_count+1 - error_info存JSON:结构化存储便于查询和展示 - 自动重试默认关闭:指数退避防雪崩 ### 测试 - 51个状态相关测试全部通过 - 无回归
Author
Owner

代码审计通过

13个文件/596行新增,状态机设计严谨。

审查要点确认:

  • 入参校验:status白名单校验 + 分页clamp保护
  • 数据迁移:alembic脚本规范,4个字段全有默认值/默认约束,向后兼容
  • 状态机:mark_pending_from_failed 清空error_info + 递增retry_count,逻辑正确
  • 自动重试配置:默认关闭,指数退避防雪崩设计合理
  • 51个状态相关测试,新增error_info/retry/auto_retry三类测试覆盖到位
  • 原地重试复用task_id,保留历史关联,设计合理

小建议(非阻断):

  • worker端实际的自动重试调度逻辑未见(只加了配置字段),应该是后续PR,注意对齐最多5次+指数退避的设计
## ✅ 代码审计通过 13个文件/596行新增,状态机设计严谨。 **审查要点确认:** - ✅ 入参校验:status白名单校验 + 分页clamp保护 - ✅ 数据迁移:alembic脚本规范,4个字段全有默认值/默认约束,向后兼容 - ✅ 状态机:mark_pending_from_failed 清空error_info + 递增retry_count,逻辑正确 - ✅ 自动重试配置:默认关闭,指数退避防雪崩设计合理 - ✅ 51个状态相关测试,新增error_info/retry/auto_retry三类测试覆盖到位 - ✅ 原地重试复用task_id,保留历史关联,设计合理 **小建议(非阻断):** - worker端实际的自动重试调度逻辑未见(只加了配置字段),应该是后续PR,注意对齐最多5次+指数退避的设计
xiaoxia added 2 commits 2026-07-14 09:17:41 +08:00
- 数据库:generation_tasks 新增 error_info JSON / retry_count / auto_retry_enabled / auto_retry_max 字段
- 领域模型:mark_failed 支持结构化 error_info,mark_pending_from_failed 递增 retry_count
- Repository:新增 list_by_user_filtered / count_by_user_filtered / list_by_project_filtered / count_by_project_filtered
- Use Case:新增 RetryGenerationTaskUseCase(原地重试)、ListUserTasksFilteredUseCase
- API:任务列表支持 status/task_type 筛选+分页,重试改为原地重试(复用task_id)
- Worker:失败时结构化记录 error_info(含堆栈摘要),支持自动重试(指数退避,最大60s)
- Schema:所有响应新增 error_info / retry_count / auto_retry 字段
- 单测:新增9个测试用例,51个状态测试全绿,80个相关测试无回归
chore: 修复black/isort格式
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 19s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m11s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 24s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 3m30s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
ce65e9439b
xiaoxia force-pushed feat/task-center-upgrade from d9cc3b40bd to ce65e9439b 2026-07-14 09:17:41 +08:00 Compare
xiaoxia added 1 commit 2026-07-14 09:26:38 +08:00
chore: 格式化alembic迁移文件
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
900fbad18e
xiaoxia added 1 commit 2026-07-14 09:26:51 +08:00
chore: 修复alembic的isort排序
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 30s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 18s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 59s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m4s
5c582e0983
xiaoxia added 1 commit 2026-07-14 09:41:39 +08:00
fix: 修复alembic迁移版本号与develop不匹配的问题
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 36s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m20s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m22s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Failing after 1m43s
6c58e14951
xiaoxia added 1 commit 2026-07-14 09:53:06 +08:00
chore: 更新schema metadata snapshot
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 41s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m27s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m43s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Failing after 1m11s
761b21fbb6
xiaoxia merged commit 94aead4342 into develop 2026-07-14 09:55:53 +08:00
xiaoxia deleted branch feat/task-center-upgrade 2026-07-14 09:55:53 +08:00
Sign in to join this conversation.