257 Commits

Author SHA1 Message Date
wangdl
3e7c02a932 fix(build): exclude scripts from tsconfig, fix JsonValue type errors
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 25s
- tsconfig.build.json: exclude scripts/ (avoids Prisma delegate mismatch)
- tsconfig.json: add exclude for scripts/ and dist/
- ai-job-artifact.repository.ts: cast metadata to any (JsonValue compat)
- ai-job-snapshot.repository.ts: cast data to any (JsonValue compat)
- ai-job-artifact.repository.spec.ts: remove unused @ts-expect-error
- snapshot-builder.service.spec.ts: cast JSON fields to any

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 12:43:56 +08:00
wangdl
98e442e666 fix(M-AI-02-GATE): restore physical column names, composite UNIQUE, lifecycle spec, migrate deploy
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 23s
Section 2: @map("errorMessage") + @map("completedAt") decouple logical from physical names.
  Forward-fix migration reverts physical columns to original names.
Section 3: jobType VARCHAR(64) → VARCHAR(32) restored.
Section 4: lifecycleStatus mapping restored to spec (pending→queued, processing→running,
  completed→succeeded, failed→failed). Enum: created|queued|running|retrying|succeeded|
  failed|cancel_requested|cancelled.
Section 5: idempotencyKey UNIQUE changed from single-column to composite
  (userId, jobType, idempotencyKey). MySQL allows multiple NULLs.
Section 6: triggerType backfill now documents evidence basis per record.
Section 7: CI deploy.yml uses prisma migrate deploy (not db push).
  Migration baseline established (28 rows in _prisma_migrations).

prisma migrate diff: No difference detected.
332 tests pass.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 12:39:56 +08:00
wangdl
0dab626cd8 feat(M-AI-02-07): transactional OutboxEvent model
- 16 columns, dedupeKey UNIQUE, (status,availableAt) + (lockedAt) indexes
- CAS markProcessing (updateMany where status='pending')
- createInTransaction(tx) for atomic Job+Outbox writes
- 12 unit tests (CAS, transaction, lock release, constraints)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 12:24:36 +08:00
wangdl
7cc6947e41 feat(M-AI-02-06): polymorphic AiJobArtifact model
- 7 columns, (jobId,artifactType,artifactId) UNIQUE for idempotency
- ON DELETE CASCADE, (jobId,ordinal) + (artifactType,artifactId) indexes
- P2002 catch → findUnique → retry-create for CASCADE race edge case
- 12 unit tests (idempotency, batch, reverse lookup, constraint)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 12:24:33 +08:00
wangdl
1fadb724ec feat(M-AI-02-05): immutable AiJobSnapshot model
- 9 columns, jobId UNIQUE, ON DELETE CASCADE
- Repository: create + findByJobId only (no update/upsert)
- 14 unit tests (immutability, security, delete strategy)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 12:24:28 +08:00
wangdl
f4259e70a0 fix(M-AI-02-04): adapt source to renamed Prisma fields
- completedAt → finishedAt, errorMessage → internalErrorMessage
- API JSON keys preserved for backward compat

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-20 12:24:24 +08:00
wangdl
bd60c2786f fix: correct require paths for dist/src output + systemd user
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
- worker.main.ts: require('../../package.json') for dist/src/ location
- worker-heartbeat.service.ts: require('../../../package.json') + try/catch
- systemd units: User=ubuntu (www-data not present on production)
- EnvironmentFile: /opt/zhixi/env/.env.production

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 21:26:05 +08:00
wangdl
cdc228ccf0 fix: break circular dependency between queue-definitions and queue-service
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
Extract queue name constants to queue.constants.ts to resolve
the require cycle that caused 'Cannot read properties of undefined'
at startup. Both queue-definitions.ts and queue.service.ts now
import from the shared constants file.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 21:24:33 +08:00
wangdl
4fb652d273 feat: M-AI-01 Worker 进程边界与部署收口(全 8 个 Issue)
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 39s
M-AI-01-01: ADR-001 统一 AI 架构决策记录 + 附录 A 依赖闭包审计
M-AI-01-02: Worker 执行依赖闭包审计(附录 A 文档)
M-AI-01-03: 分离 AppModule/WorkerModule Processor 注册
M-AI-01-04: 统一 Queue Definition Registry + 环境变量覆盖
M-AI-01-05: 独立 Worker 启动与生命周期(instanceId/校验/优雅关闭)
M-AI-01-06: Docker + systemd 部署拓扑(unit 文件 + 回滚文档)
M-AI-01-07: Worker Heartbeat(Redis TTL 90s)+ Admin 在线状态 API
M-AI-01-08: 集成验收脚本

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 21:22:48 +08:00
wangdl
d7647cbc3d fix: move all-sources route before :id to avoid conflict
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 48s
2026-06-19 15:38:32 +08:00
wangdl
178666627b feat: add GET /admin-api/knowledge-bases/all-sources
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s
2026-06-19 15:31:03 +08:00
wangdl
1abc89be23 fix: add enrichWithNames to chat sessions API
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
2026-06-19 13:30:09 +08:00
wangdl
9a392ba274 fix: add enrichWithNames to content-safety checks
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 48s
2026-06-19 13:27:10 +08:00
wangdl
0203ccfd1f fix: translate learning record titles to Chinese
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 49s
2026-06-19 13:20:29 +08:00
wangdl
0ea36a7073 feat(API-ADMIN-010): add enrichWithNames to admin list controllers
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 50s
- New shared helper: src/common/helpers/name-resolver.ts
- Applied to: reviews, users/members, files, knowledge-bases, imports
- Learning service refactored to use shared helper

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 13:04:55 +08:00
wangdl
ff4135b7c6 feat: add enrichWithNames to admin learning API
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 50s
All list endpoints now return userName, kbName, materialName
resolved from User, KnowledgeBase, KnowledgeSource tables.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 12:41:46 +08:00
wangdl
af8d95cdb6 fix: add try-catch + error logging to processBatch
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 48s
Prevents 500 from crashing the entire batch. Logs the actual error
to server log for debugging.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 12:18:46 +08:00
wangdl
fb7ee358ce fix: add knowledgeBaseId to ReadingEventUploadItemDto + increase Max delta
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s
iOS sends knowledgeBaseId in batch upload but DTO didn't have it,
causing forbidNonWhitelisted to reject with 400.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-19 12:15:56 +08:00
wangdl
43293a48e6 fix: return 'id' instead of 'jobId' in POST /imports response
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
iOS ImportStatusResponse expects 'id' field. The mismatch caused
DecodingError.keyNotFound on the client side.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 22:27:02 +08:00
wangdl
aef8e2a416 fix: make import lock unique per attempt + release in finally
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s
- Add timestamp to lock key to prevent blocking retries
- Wrap create logic in try-finally to always release lock
- Reduce lock TTL from 30min to 5min

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 22:17:59 +08:00
wangdl
433e0095ee debug: add detailed logging to DocumentImportService.createImport
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 49s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 22:16:17 +08:00
wangdl
4f614f9d1f fix: extract userId from JWT in POST /imports controller
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s
DocumentImport.userId is a required foreign key, but the iOS app
doesn't send it. Extract from JWT via @CurrentUser() decorator
and pass to service.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 22:13:10 +08:00
wangdl
0867b4f39a feat(API-AI-082): add POST /sources/:id/parse trigger endpoint
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
Allows users to manually retry source parsing by creating a new
DocumentImport job and enqueuing it. Returns jobId for polling.

Route: POST /knowledge-bases/:kbId/sources/:id/parse

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 21:56:31 +08:00
wangdl
939adcebd3 feat(API-AI-081): add KnowledgeItem.sourceId FK to KnowledgeSource
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
- Prisma schema: add sourceId field + @relation to KnowledgeSource
- KnowledgeSource: add items[] reverse relation + @index on sourceId
- KnowledgeItemsRepository: accept sourceId in create()
- ImportCandidateService.accept(): pass sourceId to create()
- DocumentImport worker: pass sourceId alongside sourceRef

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 21:54:58 +08:00
wangdl
76bdba330d fix(API-AI-080): enqueue import job + pass sourceId in KnowledgeSource pipeline
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
KnowledgeSourceService.addSource() was creating Source + DocumentImport
records but never enqueuing the job for processing. Also the worker
wasn't linking created KnowledgeItems back to their source.

Changes:
- Inject QueueService + RedisService into KnowledgeSourceService
- Enqueue document-import job after creating Source + DocumentImport
- Set Redis status keys (matching DocumentImportService pattern)
- Worker: resolve sourceId from job data or DocumentImport record
- Worker: pass sourceRef when creating KnowledgeItems

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 21:51:49 +08:00
wangdl
137fe36a72 fix: enable implicit conversion in StrictValidationPipe
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
Query string params (page=1&limit=5) arrive as strings but DTOs expect
@IsInt(). enableImplicitConversion tells class-transformer to auto-cast
types based on the DTO decorators.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 19:27:40 +08:00
wangdl
82e3a60101 refactor: merge admin/learning into admin-api/learning, restore API isolation
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
- Move AdminLearningService + DTOs to learning-session module
- Merge 21 new endpoints into existing admin-api/learning controller
- Add analysis and ai-usage methods to unified service
- Delete admin-learning module (no longer needed)
- Revert JwtAuthGuard /api/admin bypass (was breaking isolation)
- Fix: /api/* now exclusively serves user/iOS traffic again

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 19:26:37 +08:00
wangdl
04da939a22 fix: correct admin path bypass in global JwtAuthGuard
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
request.path includes the global 'api' prefix, so /admin/learning
routes appear as /api/admin/learning. Bypass /api/admin in addition
to existing /admin-api and /internal paths.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 19:00:38 +08:00
wangdl
bc11adfbac fix: allow /admin/ paths through global JwtAuthGuard
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
Global JwtAuthGuard was blocking /admin/learning/* requests before
AdminAuthGuard could process x-api-key. Now bypasses all /admin/*
paths (not just /admin-api/*), letting controller-level admin auth
handle those routes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 18:58:56 +08:00
wangdl
ed2dcb02f6 feat: add AdminApiKey permanent token for automated testing
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 50s
- Add AdminApiKey model (keyHash, expiresAt nullable for permanent)
- Extend AdminAuthGuard to accept x-api-key header as fallback auth
- Seed creates test-admin@zhixi.com with permanent SUPER_ADMIN API key
- Key format: zxat_<64 hex chars>, stored as SHA-256 hash

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 18:52:04 +08:00
wangdl
c3fd6a221f fix: add missing /api/admin/learning/knowledge-bases endpoint
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
Dashboard filter dropdown calls this to populate KB selector.
Returns knowledge bases that have reading event data with real titles.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 18:40:40 +08:00
wangdl
c0a8f7ef27 perf: add missing indexes + fix learning admin query performance
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s
- Add 10 missing DB indexes across 5 tables (LearningSession,
  ReadingEvent, MaterialReadingProgress, DailyLearningActivity,
  LearningRecord) to eliminate full-table scans on count queries
- Dashboard: accept knowledgeBaseId/dateRange filters from frontend
- getAnomalies: add skip-based pagination, remove redundant counts
- Remove duplicate AdminReadingController to fix route collision
  on admin/learning prefix

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 18:20:44 +08:00
wangdl
4a69d14047 test: add integration tests for snapshot-builder.service (API-AI-068)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
- 59 tests covering buildSnapshot full flow + all computational methods
- buildSnapshot: defaults, privacy flags, priority rules, DB persistence, error logging
- Scope routing: material vs knowledge_base session queries
- Computational methods: weightedQuizScore, weightedReviewScore, AIScore,
  weakPointSeverity, quizTrend, compositeMastery, classifyMasteryLevel
- Quality: normalizeQualityPreference, getScoreWeights presets
- Device: mapPlatformCategory, computeSwitchFrequency, mapDeviceTaskSuitability
- Helpers: modeOf, buildAllowedFields, countBy, computeSignals

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 12:23:52 +08:00
wangdl
3e43b2b52d test: add unit tests for runtime-internal.controller (API-AI-067)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
- 12 tests covering all 9 endpoints + instanceId extraction
- instanceId: from header / default "unknown"
- pollJobs: limit default 5, capabilities pass-through
- lockJob/heartbeatJob: runtimeInstanceId fallback from dto→header
- getSnapshot: direct delegation
- resolveCredential: all fields + undefined credentialId
- submitResult/submitFailure: entire dto pass-through
- submitInvocationLogs: logs array extraction

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 12:19:06 +08:00
wangdl
5fbd437232 test: add unit tests for credential-encryption.service (API-AI-066)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
- 17 tests covering encrypt/decrypt/hash/mask/redact + config error
- encrypt↔decrypt round-trip, random IV, base64, empty, unicode
- hash: deterministic, different inputs, empty string
- mask: long keys (4+****+4), short keys (2+****), edge cases
- redact: sk- token replacement, no-op, short sk- skip, empty
- Missing CREDENTIAL_ENCRYPTION_KEY throws on encrypt/decrypt

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 12:16:53 +08:00
wangdl
4713758344 test: add unit tests for platform-budget.service (API-AI-065)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
- 15 tests covering all 6 public methods
- checkPlatformBudget: healthy, auto-create, circuit-open, half-open limit,
  half-open pass, token exceeded, cost exceeded
- recordSuccess: upsert with reset circuit to closed
- recordFailure: increment failedCount, open circuit at threshold, first-day create
- Admin: transitionToHalfOpen / closeCircuit
- getBudgetState: state + limits, auto-create fallback

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 12:15:20 +08:00
wangdl
c433b3dc5d refactor: split shared mockFindUnique into settings/usage mocks in quota tests
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
- userAiSettings.findUnique → mockSettingsFindUnique
- userAiUsageDaily.findUnique → mockUsageFindUnique
- Eliminates order-dependency of mockResolvedValueOnce chains

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 12:14:33 +08:00
wangdl
9c7247aa90 test: add unit tests for user-ai-quota.service (API-AI-064)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 48s
- 15 tests covering all 4 public methods
- checkQuota: pass under limits, defaults, null usage, job/token exceeded
- incrementJobCount: correct upsert params, apiKeyMode routing
- recordTokenUsage: all token fields, costEstimate default=0
- getUsage: both modes parallel, defaults for null records, mixed

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 12:12:57 +08:00
wangdl
1a5e040ed8 test: add unit tests for user-ai.controller (API-AI-063)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s
- 34 tests covering all 28 endpoints
- Profile: GET/PUT with null→{} fallback
- Settings: GET/PUT delegation
- Credentials: CRUD + test (6 endpoints)
- Analysis Jobs: create/cancel/get/list with query filters
- Publish: quiz + flashcard
- Analysis Results: getAnalysis/listAnalyses/listRecommendations/listWeakPoints
- Quizzes: get/getQuestions/list with filters
- Reanalysis/Notifications/Feedback/Flashcards
- Fix: getProfile ?? {} now awaits before null-coalescing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:57:38 +08:00
wangdl
b0e9796acb fix: use ConfigService for DeepSeek base URL in testCredential
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
- Replace hardcoded 'https://api.deepseek.com/v1/models' with config lookup
- Single source of truth via ai.deepseek.baseUrl (DEEPSEEK_BASE_URL env)
- Add ConfigService dep to UserAiService constructor + test mock

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:47:59 +08:00
wangdl
cb24e5fb96 fix: job-reaper batch-loop instead of single take:500 to avoid missing jobs
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
- Replace single findMany(take:500) with cursor-based while loop
- REAP_BATCH_SIZE=500 constant; processes all stuck running + expired jobs
- Prevents missing jobs when >500 are stuck simultaneously
- Update tests: reset mocks before custom chains, explicit call ordering

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:45:36 +08:00
wangdl
c0594c518d test: add concurrent resolveSnapshot race test (API-AI-R01)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s
- Simulates two concurrent getSnapshot calls with no valid snapshot
- Documents the known race: both trigger buildSnapshot, second update overwrites first
- Verifies both calls complete without error (accepted-risk behavior)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:41:35 +08:00
wangdl
7725b3d2ea perf: replace N+1 dedup queries with batch pre-fetch in convertCandidates
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
- convertQuizCandidates: batch findMany all stems before loop, dedup in-memory
- convertFlashcardCandidates: batch findMany all fronts before loop, dedup in-memory
- 50 items now = 1 query instead of 50
- Update tests: mock findMany instead of per-item findFirst

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:40:41 +08:00
wangdl
c2e5590718 fix: add observability to fire-and-forget persistResult & notifyJobComplete
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
- Add static counters: persistResultFailures, notifyFailures
- Replace .catch(() => {}) with logger.error + counter increment
- Add error-path unit tests for both counter increments
- Reset counters in beforeEach for test isolation

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:38:30 +08:00
wangdl
7aea03f6e0 fix: clarify quota check is read-only, prevent refactoring pitfalls
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
- Rename checkAndReserve→checkQuota (method only reads, does not reserve)
- Add doc comment: incrementJobCount is the actual quota reservation
- Update user-ai.service.spec.ts references
- Add comments for apiKeyMode/credentialId reassignment in budget fallback

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:36:01 +08:00
wangdl
c88af39673 feat: AI Runtime 完整业务逻辑实现
All checks were successful
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
eba9632a4e test: sync runtime-internal.service tests with current implementation (API-AI-062)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:12:02 +08:00
wangdl
02979e3c24 test: add unit tests for runtime-internal.service (API-AI-062)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-18 11:03:23 +08:00
wangdl
012e26b950 feat: API-Runtime 版本兼容协议 (API-AI-072)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
- pollJobs: 记录/更新 RuntimeInstance (capabilities + heartbeat)
- submitResult: 校验 schemaVersion 匹配 job.outputSchemaVersion
- heartbeat: 首次调用设置 startedAt
- 错误码: RESULT_SCHEMA_UNSUPPORTED + RUNTIME_VERSION_INCOMPATIBLE

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-11 21:42:02 +08:00
wangdl
00ac32a103 feat: 平台 AI 预算、成本熔断与全局限流 (API-AI-071)
All checks were successful
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