feat(api): add conversation archive with vector search (MS22-DB-004, MS22-API-004)
- Add ConversationArchive Prisma model with pgvector(1536) embedding field - Migration: 20260228000000_ms22_conversation_archive - NestJS module at apps/api/src/conversation-archive/ with service, controller, DTOs, spec - POST /api/conversations/ingest — ingest session logs, auto-embed via EmbeddingService - POST /api/conversations/search — vector similarity search with agentId filter - GET /api/conversations — paginated list with agentId + date range filters - GET /api/conversations/:id — fetch full conversation including messages - Register ConversationArchiveModule in app.module.ts - 8 unit tests, all passing (vitest) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
48
docs/scratchpads/ms22-conversation-archive.md
Normal file
48
docs/scratchpads/ms22-conversation-archive.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# MS22 — Conversation Archive Module
|
||||
|
||||
## Objective
|
||||
|
||||
Implement ConversationArchive module: ingest OpenClaw session logs, store with vector embeddings for semantic search.
|
||||
|
||||
## Deliverables
|
||||
|
||||
1. ConversationArchive Prisma model
|
||||
2. NestJS module at apps/api/src/conversation-archive/
|
||||
3. Endpoints: ingest, search, list, get-by-id
|
||||
4. Register in app.module.ts
|
||||
5. Migrate, lint, build, commit
|
||||
|
||||
## Plan
|
||||
|
||||
- Add model to schema.prisma (end of file)
|
||||
- Add relation to Workspace model
|
||||
- Create module structure: dto/, service, controller, spec, module
|
||||
- Use EmbeddingService from knowledge module (import KnowledgeModule or just PrismaModule + embed inline)
|
||||
- Follow pattern: AuthGuard + WorkspaceGuard + PermissionGuard
|
||||
- Endpoint prefix: conversations (maps to /api/conversations)
|
||||
- Vector search: $queryRaw with <=> operator (cosine distance)
|
||||
|
||||
## Assumptions
|
||||
|
||||
- ASSUMPTION: Embedding is stored inline on ConversationArchive (not a separate table) — simpler and sufficient for this use case, matches MemoryEmbedding pattern
|
||||
- ASSUMPTION: Import KnowledgeModule to reuse EmbeddingService (it exports it)
|
||||
- ASSUMPTION: messageCount computed server-side from messages array length on ingest
|
||||
- ASSUMPTION: Permission level WORKSPACE_MEMBER for ingest/search, WORKSPACE_ANY for list/get
|
||||
|
||||
## Progress
|
||||
|
||||
- [ ] Schema model
|
||||
- [ ] Migration
|
||||
- [ ] DTOs
|
||||
- [ ] Service
|
||||
- [ ] Controller
|
||||
- [ ] Spec
|
||||
- [ ] Module
|
||||
- [ ] app.module.ts registration
|
||||
- [ ] Lint + build
|
||||
- [ ] Commit
|
||||
|
||||
## Risks
|
||||
|
||||
- EmbeddingService exports from knowledge.module — need to import KnowledgeModule
|
||||
- Migration requires live DB (may need --skip-generate flag if no DB access)
|
||||
Reference in New Issue
Block a user