wangdl
8776f1e7ca
fix: circular dependency AiRuntimeModule <-> AiJobModule
...
Deploy API Server / build-and-unit (push) Successful in 37s
Deploy API Server / current-integration (push) Successful in 33s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Failing after 42s
M-AI-07-05 added AiJobModule import to AiRuntimeModule, but
AiJobModule already imports AiRuntimeModule (for SnapshotBuilderService).
Use forwardRef(() => AiJobModule) to break the cycle.
Root cause of deploy crash-loop: NestJS UndefinedModuleException
at AiJobModule imports index [1] (AiRuntimeModule was undefined).
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 21:07:20 +08:00
wangdl
40e772cc3a
feat(M-AI-07-05): quiz generation execution router + controller wiring
...
Deploy API Server / build-and-unit (push) Successful in 36s
Deploy API Server / current-integration (push) Successful in 31s
Deploy API Server / backward-compat (push) Successful in 0s
Deploy API Server / deploy (push) Failing after 50s
- QuizExecutionRouter: QUIZ_GENERATION_ENGINE_MODE flag routing
- legacy: UserAiService.createAnalysisJob()
- unified: SnapshotBuilder + AiJobCreationService.createJob()
- Controller: quiz_generation routes through Router
- Response compat: legacy fields + optional engineMode/lifecycleStatus
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-22 20:46:54 +08:00
wangdl
c88af39673
feat: AI Runtime 完整业务逻辑实现
...
Deploy API Server / build-and-deploy (push) Successful in 45s
- runtime-internal.service: resolveSnapshot 自动重建、persistResult 5种jobType持久化、validateOutput 校验、convertQuizCandidates/convertFlashcardCandidates 候选转换、notifyJobComplete 通知、JOB_CANCELLED处理、heartbeat 双阶段更新+取消检测
- user-ai.service: createAnalysisJob 11步流程、cancelJob、publishQuiz/publishFlashcard、getAnalysis/listAnalyses等
- user-ai.controller: 20+ 用户API端点
- 新增服务: SnapshotBuilderService、PriorityRulesService、SnapshotCleanupService、JobReaperService
- 新增模块: admin-learning (CRUD管理)
- Prisma schema: cancelRequestedAt/cancelledAt/sourceBlockIds 字段、expiresAt 索引
- 文档: ai-runtime-user-api.md、Issue 记录
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:22:03 +08:00
wangdl
00ac32a103
feat: 平台 AI 预算、成本熔断与全局限流 (API-AI-071)
...
Deploy API Server / build-and-deploy (push) Successful in 45s
- PlatformBudgetService: checkPlatformBudget / recordSuccess / recordFailure
- 熔断器: closed → open (连续失败N次) → half_open (限制任务数) → closed
- 平台日 token 预算 + 成本预算检查
- Admin 接口: transitionToHalfOpen / closeCircuit / getBudgetState
- PlatformAiBudgetDaily 已存在于 Prisma schema
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-11 21:40:47 +08:00
wangdl
5cbf20046a
feat: 用户 AI 消费额度与日限流 (API-AI-070)
...
Deploy API Server / build-and-deploy (push) Successful in 43s
- UserAiQuotaService: checkAndReserve / incrementJobCount / recordTokenUsage
- 创建 Job 前检查 maxDailyAiJobs + maxDailyTokenBudget
- Runtime 调用后更新 UserAiUsageDaily token 消耗
- user_deepseek_key 不计入平台 token 预算
- 超限返回 DAILY_JOB_LIMIT_EXCEEDED / DAILY_TOKEN_BUDGET_EXCEEDED
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-11 21:25:18 +08:00
wangdl
43e6e9029c
feat: Runtime Internal API (API-AI-028~034)
...
Deploy API Server / build-and-deploy (push) Successful in 46s
- RuntimeInternalController: 7 个 /internal/runtime/* 端点
- RuntimeInternalService: Poll/Lock/Heartbeat/Snapshot/Credential/Result/Fail/Log
- 复用 InternalAuthGuard + x-runtime-instance-id 追踪
- Job lock 防并发 (updateMany WHERE status=pending)
- Result 幂等 (resultIdempotencyKey)
- Failure retryable/non-retryable 处理
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-11 21:23:52 +08:00
wangdl
4cf2aa99fd
feat: 用户 AI 设置与 Key 管理 API (API-AI-011~015)
...
Deploy API Server / build-and-deploy (push) Failing after 10s
- UserAiController: GET/PUT /ai/profile, GET/PUT /ai/settings
- UserAiController: CRUD /ai/model-credentials, POST test
- UserAiService: Profile upsert, Settings默认创建, Key 生命周期
- CredentialEncryptionService: AES-256-GCM 加解密, SHA-256 hash, mask脱敏, 日志redact
- AiRuntimeModule 注册到 AppModule
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-11 20:39:29 +08:00