[M-AI-02-04] Expand AiAnalysisJob 生命周期、执行与输出字段 #276
Closed
opened 2026-06-19 23:30:04 +08:00 by wangdl
·
1 comment
Labels
Clear labels
adr
Area: adr
architecture
Area: architecture
area:activity
活动/统计
area:admin
管理后台
area:admin-api
area:ai
AI/RAG
area:ai-runtime
AI Runtime / AI 分析体系相关
area:analytics
area:api
API 接口
area:auth
认证与授权
area:cos
对象存储
area:database
数据库/Migration
area:import
文件导入/解析
area:knowledge
知识库/知识点
area:learning-info
area:learning-session
area:quiz
测验/自测
area:reading-event
area:reading-progress
area:review
复习系统
area:security
安全相关
audit
Area: audit
audit:api-admin-info
audit:api-info
audit:planned
已完成宏观规划,尚未代码审查
audit:reviewed
backend
Area: backend
billing
Area: billing
blocked-by:api-info-aggregation
blocked-by:api-info-core
blocked-by:api-info-ops
blocked-by:api-info-schema
blocked-by:processor
blocked-by:schema
compatibility
Area: compatibility
gate
Area: gate
infrastructure
Area: infrastructure
priority:p0
最高优先级,阻塞发布
priority:p1
高优先级,里程碑必需
priority:p2
中优先级,后续版本
prisma
Area: prisma
release
Area: release
repo:api
API 仓库 Issue
status:blocked
被阻塞
status:done
已完成
status:partial
status:todo
type:aggregation
type:bug
缺陷修复
type:design
设计
type:docs
文档
type:feature
新功能
type:migration
type:refactor
重构
type:test
work:admin-api
work:aggregation
work:api
work:artifact
题目/卡片产物
work:audit
work:circuit-breaker
熔断
work:contract
work:design
架构/协议设计工作
work:docs
work:export
work:extend-existing
work:internal-api
Runtime 内部接口
work:job
Job 调度相关
work:new-module
work:new-table
work:ops
work:query
work:quota
额度/限流
work:schema
Prisma Schema 设计
work:security
work:service
Service 层实现
work:snapshot
Snapshot 构建
work:test
Milestone
No items
No Milestone
M-AI-02 统一 AiJob 数据库 Expand
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: wangdl/api-server#276
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
依赖
目标
增加统一生命周期、执行控制、输出版本和错误字段,但不切换现有读取逻辑。
范围
按 ADR 增加:
新增生命周期 enum:
约束
lifecycleStatus初始允许为空;status字段和 enum 保留;status;验收
[M-AI-02] Expand AiAnalysisJob 生命周期、执行与输出字段to [M-AI-02-04] Expand AiAnalysisJob 生命周期、执行与输出字段开发完成评论
完成内容
lifecycleStatus、lockedBy、lockedAt、lockUntil、cancelRequestedAt、attemptCount、maxAttempts、timeoutMs、credentialMode、credentialId、modelTier、modelProvider、modelName、promptKey、promptVersion、outputSchemaVersion、outputHash、validatedOutput、errorCode、publicErrorMessageerrorMessage→internalErrorMessage、completedAt→finishedAt(lifecycleStatus, createdAt)、(queueName, lifecycleStatus, createdAt)ai-analysis.repository.ts+ai-analysis.service.ts适配新字段名(API JSON key 保持不变)Migration SQL 审查
lifecycleStatus初始 NULL(符合约束)internalErrorMessage为 TEXT NULL(保留旧数据)finishedAt为 DATETIME NULL(保留旧数据)validatedOutput为 JSON(MySQL 原生类型,无大小上限)publicErrorMessageVARCHAR(500) 与内部错误internalErrorMessageTEXT 分离修改文件
prisma/schema.prisma:AiAnalysisJob model 新增 20 字段 + 2 索引prisma/migrations/20260620000001_m_ai_02_04_lifecycle_execution/migration.sql(新增)src/modules/ai-analysis/ai-analysis.repository.ts:23-25:completedAt→finishedAt、errorMessage→internalErrorMessagesrc/modules/ai-analysis/ai-analysis.service.ts:63-64:Prisma 字段访问适配(API JSON key 保持completedAt/errorMessage向后兼容)验证
platform_key, modelTier=primary, modelProvider=deepseek, modelName=deepseek-chat, attemptCount=0, maxAttempts=3, timeoutMs=120000✅finishedAt/internalErrorMessagecorrectly carry over fromcompletedAt/errorMessage✅测试情况
npx jest --testPathPatterns="ai-analysis|ai-runtime|active-recall|feynman" --passWithNoTests未完成 / 风险
lifecycleStatus当前全部为 NULL,M-AI-02-10 回填status列保留,现有业务仍读取旧状态是否建议进入 Review