wangdl
5628e6db90
docs(M-AI-08-01): AI workflow inventory + learning analysis migration contract
...
Deploy API Server / build-and-unit (push) Successful in 36s
Deploy API Server / current-integration (push) Successful in 30s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 1m2s
Inventory: 17 AI workflows cataloged. 6 migrated, 4 in M-AI-08 scope,
5 deferred, 2 legacy pending retirement. Confirmed M-AI-08 as final
core business migration milestone.
Contract: 4 Runtime job types (learning_state/weak_point/next_action/
flashcard) to be merged into unified learning_analysis Job. Data source
matrix, snapshot schema, evidence schema, topology frozen.
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 21:31:29 +08:00
wangdl
62f324a429
docs: M-AI-07-GATE audit — PASS
...
Deploy API Server / build-and-unit (push) Successful in 39s
Deploy API Server / current-integration (push) Successful in 31s
Deploy API Server / backward-compat (push) Successful in 17s
Deploy API Server / deploy (push) Failing after 49s
All 16 completion criteria verified. 785 tests, 0 failures.
P0: 0, P1: 0. Ready for M-AI-08.
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:56:26 +08:00
wangdl
a17aba972b
docs: M-AI-07-01 quiz generation migration contract
...
Deploy API Server / build-and-unit (push) Successful in 36s
Deploy API Server / current-integration (push) Successful in 30s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 1m5s
Audit complete: 2 quiz systems (procedural + AI Runtime), 4 data models,
3 question types (choice/fill/judge), external Runtime polling architecture.
Identified 7 anomalies including answer leak (P0) and missing prompt/schema.
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:29:57 +08:00
wangdl
7fafa1b0cb
fix(M-AI-06): resolve P2-01 — modelName already corrected to deepseek-v4-flash
...
Deploy API Server / build-and-unit (push) Successful in 36s
Deploy API Server / current-integration (push) Successful in 30s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 1m1s
Root cause: modelName was 'deepseek-chat' in early Definition draft.
Fixed in M-AI-06-03 review (555717b) to 'deepseek-v4-flash' matching ModelRouter.
GATE doc P2-01 was stale — updated to reflect resolved status.
No actual model routing change occurred.
Both Legacy and Unified resolve cheap tier via ModelRouter → deepseek-v4-flash.
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:17:55 +08:00
wangdl
297c4c173c
docs: M-AI-06-GATE audit — PASS
...
Deploy API Server / build-and-unit (push) Successful in 36s
Deploy API Server / current-integration (push) Successful in 30s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 1m2s
All 14 completion criteria verified. 482 tests, 0 failures.
P0: 0, P1: 0, P2: 1 (non-blocking), P3: 3 (non-scope).
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 19:44:39 +08:00
wangdl
f1e529b99e
feat: M-AI-06 Feynman ReviewCard Child Job 与可靠生成
...
Deploy API Server / build-and-unit (push) Failing after 26s
Deploy API Server / current-integration (push) Has been skipped
Deploy API Server / backward-compat (push) Has been skipped
Deploy API Server / deploy (push) Has been skipped
完成 M-AI-06 全部 7 个 Issue:
- 01: 审计冻结契约 (docs/architecture/m-ai-06-review-card-child-job-contract.md)
- 02: AiJobCreationService.createInTransaction(tx, input)
- 03: ReviewCard Generation Job Definition + Snapshot Builder
- 04: ReviewCard Generation Executor + 输出验证 Validator
- 05: ReviewCard Generation Projector + 卡片幂等 + Engine 接入
- 06: FeynmanProjector 接入 FEYNMAN_REVIEW_CARD_MODE Feature Flag
- 07: E2E 测试 (test/m-ai-06-review-card-child.e2e-spec.ts)
核心变更:
- 新增 10 个文件, 修改 7 个文件
- 新增 createInTransaction() 外部事务支持
- 新增 review_card_generation Job Type (ai-background / cheap tier)
- FeynmanProjector 根据 Feature Flag 路由 child_job / legacy_event
- Projector 入口幂等 + P2002 回退双重保障
- 测试: 单元 482 passed, E2E 待 CI 执行
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 19:27:14 +08:00
wangdl
8987598eb8
feat(M-AI-05): track Feynman unified engine migration implementation
...
23 files (+4676/-10):
- Contract: m-ai-05-feynman-migration-contract.md (737 lines)
- Gate audit: m-ai-05-gate-audit.md (318 lines)
- Job Definition + Snapshot Builder + Registration
- Executor + BusinessValidator + ReferenceValidator
- Projector (atomic transaction + 3-layer idempotency)
- ExecutionRouter (FeatureFlag + idempotencyKey)
- ObservabilityService (structured logging + counters)
- Engine: feynman_evaluation execution branch
- AiJobCreationService: feynman_evaluation safety branch
- Controller/Module: Router injection
- CI: path detection for m-ai-05
- E2E: 8 HTTP-layer scenarios (14 total)
- Unit tests: 104 new tests (5 spec files)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 17:44:58 +08:00
wangdl
a532b5163b
fix(P2-06): remove @Optional() silent skip from AiInteractive/Background workers
...
Deploy API Server / build-and-unit (push) Successful in 34s
Deploy API Server / current-integration (push) Successful in 3m2s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Successful in 1m3s
Engine is now a hard dependency — DI resolution failure prevents Worker
startup (fail-fast) instead of silently skipping all Unified Jobs.
Changes:
- ai-interactive.worker.ts: remove @Optional(), silent return guard
- ai-background.worker.ts: remove @Optional(), silent return guard
- docs: mark P2-06 as fixed
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 15:45:33 +08:00
wangdl
4f74c09d0f
docs(M-AI-04-GATE): record P2-06 (@Optional silent skip) and P2-07 (Engine hardcoded active_recall) as technical debt
...
Deploy API Server / build-and-unit (push) Successful in 35s
Deploy API Server / current-integration (push) Successful in 30s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Has been cancelled
P2-06: AiInteractiveJobWorker @Optional() + silent return — must remove
before production Unified to prevent silent job skipping.
P2-07: Engine if (jobType === active_recall) ×4 — should refactor
to Definition lifecycle hooks or Observer pattern. Does not block M-AI-05.
Also update P1-01/P1-02 to reflect BATCH-02 fixes.
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 15:43:29 +08:00
wangdl
f8bd950f1a
fix(M-AI-04-GATE-FIX-02): Worker AiJobModule, Projector observability, E2E fail-closed
...
Deploy API Server / build-and-unit (push) Successful in 35s
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
P1-01: WorkerModule imports AiJobModule → AI_JOB_EXECUTION_ENGINE resolved
→ AiInteractiveJobWorker can execute Unified Jobs (not silently skip)
P1-02: Engine PROJECT phase wrapped in try-catch → incrementProjectorFailed
on ActiveRecall projector errors (independent of executor failures)
P2-01: E2E beforeAll fail() → throw new Error() → no ReferenceError risk
Observability coverage after fix:
- Creation: incrementUnifiedRequests, logRequest, logJobCreated, logJobCreateFailed ✅
- Execute success: incrementUnifiedExecuteSuccess, logExecutionCompleted ✅
- Execute failure: incrementUnifiedExecuteFailed, incrementUnifiedRetry, logExecutionFailed ✅
- Projector failure: incrementProjectorFailed ✅ (NEW)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 15:29:33 +08:00
wangdl
a5ad0bc9f2
docs(M-AI-04-08-GATE): final acceptance audit — CONDITIONAL PASS
...
Deploy API Server / build-and-unit (push) Successful in 34s
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 1m1s
Gate report: docs/architecture/m-ai-04-gate-audit.md
- 29 acceptance criteria: all passed
- 1 P0 fixed (cross-user ownership)
- 6 P1 archived (0 block test-env Unified)
Condition: test-env Unified only, production stays Legacy.
CI Docker ready → upgrade to PASS.
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 15:16:26 +08:00
wangdl
0ec58669dd
feat(M-AI-04): Active Recall 端到端迁移至统一 Job Engine
...
Deploy API Server / build-and-unit (push) Successful in 37s
Deploy API Server / current-integration (push) Failing after 1m35s
Deploy API Server / backward-compat (push) Successful in 17s
Deploy API Server / deploy (push) Has been skipped
M-AI-04-01: 审计并冻结迁移契约 (文档)
M-AI-04-02: 注册 JobDefinition + SnapshotBuilder (28 tests)
M-AI-04-03: Executor + BusinessValidator + ReferenceValidator (31 tests)
M-AI-04-04: Projector + Artifact + 幂等写入 (19 tests)
M-AI-04-05: 入口集成 (Router + CreationService + Engine + Executor)
M-AI-04-06: 状态兼容 + 结构化日志 + 指标计数器 (255 tests)
M-AI-04-07: 真实业务 E2E + CI 触发 + FeatureFlag 受控切换 (11 tests)
P0 修复:
- 跨用户 question 所有权校验 (active-recall.service.ts)
- E2E infra 不可用时 HARD FAIL (fail() 替代静默 skip)
添加文件:
- docs/architecture/m-ai-04-active-recall-migration-contract.md
- 12 个 ai-job 模块文件 (Definition/Snapshot/Executor/Validator/Projector/Router/Observability)
- test/m-ai-04-active-recall.e2e-spec.ts + setup
修改文件:
- active-recall.service.ts, active-recall.module.ts
- ai-job-creation.service.ts, ai-job-execution-engine.ts, ai-job.module.ts
- .gitea/workflows/deploy.yml (CI 变更检测)
- test/jest-e2e.json (setupFiles + globals)
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 14:55:33 +08:00
wangdl
8e86109162
fix: CI pipeline — 修正 E2E config + 移除不兼容的 secrets 表达式
...
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 16s
Deploy API Server / m-ai-03-synthetic-e2e (push) Failing after 9s
Deploy API Server / deploy (push) Has been skipped
- test/jest-m-ai-03.json: 移除 jose mock(prod runner 有完整 node_modules)
- deploy.yml: 修正 E2E jest config 路径 + 移除 REDIS_URL 中的 || 语法(Gitea Actions 不支持)
- E2E 文件在 test/ 目录,默认 jest rootDir=src 不会执行
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-21 10:56:22 +08:00
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