wangdl
49151117c8
fix: M-AI-03-GATE-FIX — Admin Retry 统一链路 + 队列测试修正 + E2E 激活 + CI 门禁
...
Deploy API Server / build-and-unit (push) Successful in 32s
Deploy API Server / current-integration (push) Failing after 1m34s
Deploy API Server / backward-compat (push) Successful in 16s
Deploy API Server / m-ai-03-synthetic-e2e (push) Failing after 12s
Deploy API Server / deploy (push) Has been skipped
### 一、生命周期契约核对
- ADR-003 §1.1: 5 状态(queued/running/succeeded/failed/cancelled)
- cancel_requested = cancelRequestedAt 信号(非状态)
- created/retrying 不在状态机中
- 代码完全一致 ✅
### 二、Admin Retry 修复
- retryJob 不再绕过 Registry/CreationService/Outbox
- 改为调用 AiJobCreationService.createJob()(统一事务链路)
- parentJobId + triggerType=admin_manual 正确传入
- 幂等键: admin-retry:<jobId>:<timestamp>(允许不同重试产生不同 Job)
- 原 Job 不修改,新 Job 使用新 ID
- 新增 AiJobCreationService.retrySnapshotContent 支持复用 Snapshot
### 三、队列定义测试修正
- 旧队列断言保持 6 个 legacy queues 的默认值检查
- 新增 M-AI-03 per-queue 断言(ai-interactive: concurrency=2/attempts=2/backoff=2000; ai-background: concurrency=1/attempts=3/backoff=5000/lockDuration=60s)
- lockDuration 测试改为 >= 30s(允许 per-queue 差异)
### 四、Synthetic E2E 激活
- test/m-ai-03-synthetic.e2e-spec.ts: 12 真实场景(创建/幂等/原子/cancel/JWT/隔离/脱敏/未知type/状态机)
- test/jest-m-ai-03.json: 真实 infra config(无 mock Prisma/BullMQ/Redis)
- CI Workflow 新增 m-ai-03-synthetic-e2e job
- deploy needs 新增 m-ai-03-synthetic-e2e 依赖
### 五、测试结果
- 单元测试: 471/471 passed, 0 failed
- E2E: 12 场景待 CI 真实 infra 执行
- queue-definitions: 19/19 passed
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 10:47:09 +08:00
wangdl
8b6c7cef72
fix: ADR-003 cancel_requested 信号语义 + BullMQ retry 范围 + CreateJobInput 补全
...
Deploy API Server / build-and-unit (push) Successful in 32s
Deploy API Server / current-integration (push) Successful in 29s
Deploy API Server / backward-compat (push) Successful in 1s
Deploy API Server / deploy (push) Successful in 1m2s
- §1.1.1: 明确 cancel_requested 不是独立生命周期状态,是 running 上的信号字段
- §5.5: Engine 内部 retry(业务级)vs BullMQ retry(进程崩溃)的分工表
- §2.4: CreateJobInput 对齐 #289 规格(新增 triggerType/parentJobId)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 17:12:35 +08:00
wangdl
88b35d0d18
fix: ADR-003 BullMQ jobId 加入 userId + 过渡期双写路径说明
...
Deploy API Server / build-and-unit (push) Successful in 32s
Deploy API Server / backward-compat (push) Has been cancelled
Deploy API Server / deploy (push) Has been cancelled
Deploy API Server / current-integration (push) Has been cancelled
- §3.2: BullMQ jobId 改为 {queueName}:{userId}:{jobType}:{idempotencyKey},与 Outbox dedupeKey 对齐
- §1.4.1: 新增过渡期双写路径表,明确 AiJobLifecycleRepository(新)与 AiAnalysisRepository(旧)的互斥范围及迁移计划
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 17:11:58 +08:00
wangdl
d44fe57b6d
fix: ADR-003 补充幂等流程 + 修正队列配置对齐 #288 规格
...
Deploy API Server / build-and-unit (push) Successful in 32s
Deploy API Server / backward-compat (push) Has been cancelled
Deploy API Server / deploy (push) Has been cancelled
Deploy API Server / current-integration (push) Has been cancelled
- 新增 §2.4 AiJobService.createJob 幂等流程(findUnique + insert + P2002 catch)
- §3.1 队列配置对齐 Issue #288:ai-interactive attempts=2, backoff=2000ms;ai-background concurrency=1, backoff=5000ms
- 新增设计理由说明与原始规格的偏差原因
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 17:11:18 +08:00
wangdl
947958052a
fix: ADR-003 markSucceeded/markFailed/markCancelled 接受可选 tx 参数
...
Deploy API Server / build-and-unit (push) Successful in 32s
Deploy API Server / current-integration (push) Successful in 29s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Has been cancelled
修正 §1.4 与 §6.2 矛盾:三个终态写入方法现接受可选 Prisma.TransactionClient,
Projector 路径传入 tx 共享事务保证原子性,非 Projector 路径不传 tx 使用独立事务。
lockJob 保持无 tx(CAS 必须立即对其他 Worker 可见)。
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 17:09:59 +08:00
wangdl
608129be4e
docs: ADR-003 冻结统一 Job Engine、Registry、Outbox 与状态机
...
Deploy API Server / build-and-unit (push) Successful in 31s
Deploy API Server / current-integration (push) Successful in 28s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 1m3s
冻结 M-AI-03 完整实现契约:
- 状态机:5 状态、6 允许迁移、6 非法迁移、CAS 并发、Heartbeat/Reaper
- Job Definition Registry:TypeScript 接口冻结、注册校验、禁止 switch(jobType)
- 队列:ai-interactive/ai-background/ai-analysis 配置、Payload、Worker 边界
- Outbox:ai.job.enqueue 事件、CAS 先于 queue.add 的领取算法、崩溃窗口分析
- Execution Engine:PREPARE/RESOLVE/EXECUTE/PROJECT/COMPLETE 五阶段管线
- Projector:事务边界、AiJobArtifact 幂等、失败回滚
- API:4 端点、JobStatusResponse 接口、6 公开错误码
- 安全:Credential/Redis/日志/Snapshot/Outbox payload 约束
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 17:06:13 +08:00
wangdl
8e5108751c
docs: 补充 AuditLogProcessor 行为分析 + ContentSafetyService 未使用依赖
...
Deploy API Server / build-and-unit (push) Successful in 33s
Deploy API Server / current-integration (push) Successful in 29s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 1m0s
- W4 新增 process() 方法完整代码和行为说明
- 标注因队列无生产者,Processor 从未被触发
- 新增 ContentSafetyService 注入未使用 QueueService 的依赖清理建议
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 17:03:28 +08:00
wangdl
64659825ae
docs: 修正审计文档 — 6 项 Non-blocking 问题
...
Deploy API Server / build-and-unit (push) Successful in 31s
Deploy API Server / current-integration (push) Successful in 29s
Deploy API Server / backward-compat (push) Successful in 1s
Deploy API Server / deploy (push) Successful in 1m0s
问题 5:新增 queueName 与实际队列不一致(ai-interactive vs ai-analysis)及风险标注
问题 6:移除 QueueService.add() 独立 Producer 身份,降级为基础设施注释
问题 7:细化孤儿队列描述 — 每个队列的生产者状态、WorkerModule 注册、闲置含义
问题 8:新增 STATUS_TO_LIFECYCLE 映射缺口分析(缺少 cancel_requested / cancelled)
问题 9:补充 RuntimeInternalService.notifyJobComplete() 的直接通知路径
问题 10:新增 Outbox 并发重复投递场景的时序分析
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 16:59:34 +08:00
wangdl
ed783967e8
docs: M-AI-03 审计现有 Job 创建、Worker 执行与 Outbox 接入边界
...
Deploy API Server / build-and-unit (push) Successful in 33s
Deploy API Server / current-integration (push) Successful in 29s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 58s
产出 docs/architecture/m-ai-03-current-execution-audit.md。
修正:
- 移除死代码 publishAsync() 的 Producer 身份(零调用方)
- 移除 NotificationsService.send() 的 Producer 身份(仅写 DB,不入队)
- 移除 AdminEventsController 的 Producer 身份(只读+重试,不创建 Job)
- 新增孤儿队列节:notification/domain-events/audit-logs 的 Consumer 存在但无活跃 Producer
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 16:56:39 +08:00
wangdl
4c2b8d02d7
docs(M-AI-02-GATE): update ADR-002 lifecycle spec + @map strategy
...
Deploy API Server / build-and-deploy (push) Failing after 24s
- lifecycleStatus enum: created|queued|running|retrying|succeeded|failed|cancel_requested|cancelled
- Legacy mapping: pending→queued, processing→running, completed→succeeded, failed→failed
- @map approach documented for physical column compatibility
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 12:40:26 +08:00
wangdl
800ce4a2b2
feat(M-AI-02): schema audit (02-01) + ADR freeze (02-02)
...
M-AI-02-01: Production DB audit of all 5 AI tables (9 rows, 0 orphans, 37 test refs)
M-AI-02-02: Frozen AiJob Expand ADR — 43-column schema, 6 indexes, state mapping
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 12:24:16 +08:00
wangdl
56315e454b
docs: fix appendix A line numbers and NotificationWorker dependency chain
...
- AiAnalysisWorker in worker.module.ts: line 62→64
- NotificationWorker: verified complete dependency chain (NotificationsService→NotificationsRepository+EventBusService(@Optional))
- Removed resolved "unconfirmed" item from section 六
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 20:31:08 +08:00
wangdl
54bc505f7a
docs: add ADR-001 unified AI architecture decision record
...
Freeze the architecture decision for 8-batch unified AI migration.
Covers current/target topology, API/Worker process boundaries,
5 Processors, Heavy Runtime disposition, phase-1 non-goals,
rollback principles, and cross-batch constraints.
Includes Appendix A: worker dependency closure audit.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 20:10:35 +08:00