192 Commits

Author SHA1 Message Date
fc978a5e7f feat: M4-03 — server health checks (Docker/MySQL/Redis/Qdrant/Gitea/Nginx/Worker)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 39s
- Add ServiceHealth Prisma model for health check records
- Add getHealthChecks() with local + remote service checks
- Add GET /admin-api/servers/health endpoint

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 17:51:20 +08:00
90e921366a feat: M4-02 — admin learning data views (sessions, AI analysis, AI usage logs)
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
- Add AdminLearningController with 3 endpoints:
  GET /admin-api/learning/sessions — learning sessions list
  GET /admin-api/learning/analysis — AI analysis results
  GET /admin-api/learning/ai-usage — AI usage logs

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 17:45:43 +08:00
5816ddf488 fix: add missing userTrend/aiCallTrend fields to dashboard stats response
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 17:41:53 +08:00
fb1c6fd216 feat: M4-01 — enhance admin dashboard with real metrics + caching
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
- Query real data: today's AI calls, cost, import count, failed tasks, active users, upcoming expirations
- Add Redis caching (TTL 120s) for dashboard stats
- Add POST /admin-api/dashboard/refresh endpoint
- Fix ignoreDeprecations in tsconfig (ts-jest incompatible)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 17:36:23 +08:00
2bfa9ad7c3 fix: M3 audit — scheduleState persistence, AI→ReviewCard subscriber, ActiveRecall queue, streak bug, domain events
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
- M3-02: Add scheduleState to ReviewCard model + persist in updateCard/insertCard
- M3-02: Add ReviewCardSubscriber (OnEvent 'ai.analysis.completed' → generateCards)
- M3-02: Add AdminReviewController (GET /admin-api/reviews)
- M3-01: ActiveRecall now enqueues via AiAnalysisService instead of direct workflow call
- M3-01: FocusItem model adds source field, worker uses status:'open'
- M3-03: Fix streak calculation (break on gap), add StreakUpdatedEvent/DailyGoalAchievedEvent
- M3-03: Add LearningGoal/StreakRecord/LearningStats to Prisma schema
- M3-03: Fix FocusItem recommendation query (status:'pending' → 'open')

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 16:17:34 +08:00
8e5d722a1e feat: M3-04/05/06 — Workspace Experience, Notification, Cache Module
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 44s
M3-04: RecentItem/Favorite/SearchHistory models, Tag CRUD, global search, workspace dashboard
M3-05: NotificationPreference/PushToken/Template models, preferences, push tokens, admin templates
M3-06: CacheService with wrap() penetration protection, key naming conventions, admin cache management
E2E: 27 new tests for M3-04/05/06 (35/36 passing overall)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 16:01:34 +08:00
4be418ef4a fix: TypeScript errors — string→number, activityDate, remove easeFactor from update
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
- import-candidate: explicit any[] type for safeCandidates
- growth: date→activityDate (actual DailyLearningActivity field name)
- review: Number(rating) for SM-2 math, remove easeFactor from updateCard call

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 14:25:54 +08:00
3f2ba8ba93 fix: remove invalid distinct option from Prisma findMany
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 19s
Prisma v5.22 findMany does not support distinct — handled in JS instead.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 14:23:36 +08:00
098b8055f5 feat: M3-03 — Growth & Retention, streak + recommendations
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 19s
- GrowthService: streak calculation from DailyLearningActivity
- Recommendations: focus items, due review cards, new knowledge items
- New API: GET /api/activity/streak, GET /api/activity/recommendations

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 14:16:14 +08:00
cddcf57a93 feat: M3-02 — Review Engine, Anki SM-2 algorithm + schedule state machine
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 19s
- Anki SM-2 interval calculation (learn/review/relearn states)
- Proper ease factor adjustment based on rating
- ScheduleState tracking (new/learning/review/relearning)
- ReviewSession submit returns nextReviewAt/scheduleState/intervalDays

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 14:11:58 +08:00
c840531eea feat: M3-01 — Learning Engine, AIAnalysisCompleted event + FocusItem generation
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 18s
- Publish AIAnalysisCompleted domain event after each AI analysis
- Auto-generate FocusItems from AI-identified weaknesses
- Review Engine subscribes to AIAnalysisCompleted to create ReviewCards

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 14:04:47 +08:00
3c242a807a fix: M2-02/06 audit — system KB seed + candidate Content Safety
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 19s
- SystemKnowledgeBaseSeed: auto-creates built-in 新手引导知识库
- Content Safety check on candidate accept() and createCandidates()

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 13:58:50 +08:00
0c07b59765 fix: add @Optional() to ContentSafetyService in RagChatService
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 41s
Same issue as KnowledgeBaseService — NestJS can't resolve
ContentSafetyService in RagChatModule without @Optional().

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 13:46:30 +08:00
7ae94d9178 feat: M2-08 — Knowledge Ops, chunk viewer + RAG debug + candidate inspector
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 33s
- Chunk viewer AAPI (by sourceId)
- RAG debug search endpoint
- KnowledgeOps admin page (candidate inspection, chunk management, RAG debug)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 13:43:23 +08:00
98bc9961ba feat: M2-07 — RAG Chat module with sessions, messages, citations
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 33s
- ChatSession/ChatMessage/ChatCitation Prisma models
- CAPI: create/list sessions, send message, get history, delete
- Admin AAPI: view user sessions and messages
- Content safety integration on user input
- Placeholder RAG pipeline (real pipeline in M3)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 13:39:14 +08:00
06351c7381 feat: M2-06 — Artifact model + KnowledgeItem.learnable + Admin AAPI
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 39s
- Artifact base model for future FlashcardSet/Quiz/StudyGuide
- KnowledgeItem.learnable boolean (default true) for M3 LearningSession
- Admin AAPI: GET candidates (by status/kbId), GET items (by kbId)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 13:34:24 +08:00
68540b0d67 feat: M2-05 — Vector integration contracts + citation context assembler
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 38s
- integration-types.ts: IndexableChunk, CitationContext, RetrievalRequest/Response
- VectorService.buildCitationContexts() for RAG citation assembly
- Defines Ingestion↔Vector↔RAG interface contracts

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 13:28:05 +08:00
9520d1f549 feat: M2-04 — Ingestion & Indexing, ImportStepLog + Admin monitor AAPI
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 42s
- ImportStepLog model for tracking each import pipeline step
- Admin AAPI: import list, detail with step logs, retry failed
- Admin page: ImportMonitor with drawer detail view

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 13:12:16 +08:00
932bf362df fix: remove debug test-run step, restore normal CI + cleanup main.ts
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 34s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 12:50:19 +08:00
f0ddd7cf38 fix: add try-catch to all OnModuleInit hooks to prevent startup crashes
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 34s
- PrismaService.onModuleInit: catch DB connection failures
- CostAggregationService.onModuleInit: catch aggregation errors
- MetricsCleanupService.onModuleInit: catch cleanup errors

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 12:48:30 +08:00
80ac9f9834 fix: add global uncaught exception handlers to capture startup crashes
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 31s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 12:38:30 +08:00
b71371cd1c fix: lazy-init Qdrant connection to prevent app startup hang
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 34s
VectorService.onModuleInit() was blocking NestJS startup trying to
connect to Qdrant, causing systemd restart timeout. Changed to lazy
initialization: Qdrant client connects on first actual request only.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 12:14:14 +08:00
81c49ca067 fix: add @Optional() to ContentSafetyService in KnowledgeBaseService
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 33s
NestJS couldn't resolve ContentSafetyService because ContentSafetyModule
is not imported in KnowledgeBaseModule, causing app startup crash.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 11:42:41 +08:00
b3bce7ff78 feat: M2-03 — Material & Source, SourceReference citation tracking
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 11s
- SourceReference model for artifact→chunk→source citation chain
- Admin source list + reference tracing endpoints
- Existing KnowledgeSource already covers Material status/version

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 11:31:46 +08:00
052cd5cba8 feat: M2-02 — Workspace + KnowledgeBase + Folder management
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 11s
- Workspace + KnowledgeFolder Prisma models
- Folder CRUD: create/list/update/delete (soft-delete with children)
- Content Safety integration for KB title on create/update
- E2E: KB create, folder CRUD, admin KB list

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 11:23:58 +08:00
292e7e5638 feat: M2-01 — User & Account deepening, membership + deletion + devices
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 33s
- UserDevice + AccountDeletionRequest Prisma models
- CAPI: membership query, deletion request/cancel, device list/remove
- AAPI: membership assign, deletion approve/reject, device view

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 11:18:56 +08:00
14eaad53c3 fix: auto-aggregate AI costs hourly instead of manual-only
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 33s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 11:13:02 +08:00
eb62868e8f feat: M1-06 — Quota/Cost closing, AI cost aggregation + reports + CSV export
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 39s
- CostAggregationService: AiUsageLog → CostDailySummary daily aggregation
- AAPI: cost report by provider/model/daily trend, CSV export, top consumers
- Manual aggregation trigger endpoint

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 11:03:52 +08:00
809f125107 feat: M1-05 — Observability deepening, AI + Worker performance metrics
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 39s
- GET /admin-api/metrics/ai — AI调用耗时按provider/模型分组
- GET /admin-api/metrics/worker — Worker任务按队列统计成功率
- Admin page: AI performance + Worker performance tabs

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:56:36 +08:00
a08fd4970a feat: M1-04 — Content Safety deepening, reports CAPI, violation records
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 39s
- Add ViolationRecord table (Prisma + migration)
- CAPI POST /api/reports for user report submission
- AAPI reports list + handle, violations list + penalty apply
- Admin page: reports management + violation records tabs

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:53:19 +08:00
90c27ee979 fix: don't crash on startup when SECRET_MASTER_KEY is not set in production
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
Changed getMasterKey() from throwing Error at module load time to logging
a critical console.error, so the app can still start without the env var.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:46:20 +08:00
af800b2eb5 fix: TypeScript build errors — RedisService.keys(), eventBus void, Qdrant API
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 22s
- Add keys() method to RedisService for WorkerHeartbeat
- Wrap eventBus.publish() calls in try/catch (returns void)
- Fix Qdrant createPayloadIndex API signature (2 args, not 3)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:22:56 +08:00
5fd737967f feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 23s
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log

M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger

M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint

M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation

E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
d32411760f feat: M0-12 Secret & Vendor Asset — AES-256-GCM encrypted key storage + Admin AAPI
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 38s
2026-05-23 20:36:39 +08:00
2a3f55c58e fix: simplify dashboard — skip missing tables
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 22s
2026-05-23 20:28:10 +08:00
28ff67c69e fix: BigInt for sizeBytes
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 1s
2026-05-23 20:26:44 +08:00
6aa24cc5bb fix: dashboard safe queries for missing tables + workflow prisma generate
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
2026-05-23 20:26:34 +08:00
fd1897d385 feat: M0-11 — QuotaService + Redis deduction + Admin AAPI + CostDailySummary + UserMembership
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 21s
2026-05-23 20:13:49 +08:00
d88233fd5b feat: M0-10 — audit log for manual task retry
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 39s
2026-05-23 20:08:54 +08:00
7a31bd3702 fix: revert AdminAuditService to PrismaService — queue not available in auth module
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 41s
2026-05-23 19:57:43 +08:00
903474b7c2 fix: eventBus at end of params
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 35s
2026-05-23 19:48:18 +08:00
7c1e439c3b fix: reorder optional params
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
2026-05-23 19:48:06 +08:00
466acc7e83 fix: return empty string when queue unavailable
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
2026-05-23 19:47:55 +08:00
ad0e4f397a fix: break circular dependency between EventBusService and QueueService
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
2026-05-23 19:47:40 +08:00
99d03bb26c feat: M0-10 — TaskLog table + task events + retry audit
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 32s
2026-05-23 19:29:08 +08:00
2c6d56bcfc feat: M0-10 — Task types enum + worker heartbeat + Domain Events for tasks
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
2026-05-23 19:27:46 +08:00
9244db05b4 feat: M0-09 — BullMQ cleanup queue + Domain Events + async COS delete
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 35s
2026-05-23 09:47:30 +08:00
7eb7427817 fix: use hard delete
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 40s
2026-05-23 09:44:39 +08:00
8d08b0ed9c fix: remove deletedAt filter
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
2026-05-23 09:44:32 +08:00
32be0d8831 feat: M0-09 admin files AAPI
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
2026-05-23 09:44:19 +08:00