d2fed6087a
- Introduced `mcp-server.js` to expose KXKM personas as MCP tools, supporting chat, persona listing, web search, and status checks. - Implemented `mcp-server-smoke.js` for testing the MCP server functionality, ensuring compatibility with both new and legacy message formats. - Created `setup-voice-clone.sh` for managing voice cloning environment setup, including bootstrapping, sample generation, and smoke testing. - Added `state.json` to track project status and task outputs for various batches. - Generated summary files for deep cycle and overall project status, capturing performance and security findings.
4.4 KiB
4.4 KiB
Deep Audit 2026-03-19
Analyse exhaustive par 3 agents paralleles (backend, frontend, packages) + veille OSS.
Resultats validation
- check:v2: OK (TypeScript vert)
- test:v2: 204 tests, 0 fail, 320ms
Metriques globales
| Couche | LOC | Tests LOC | Couverture estimee |
|---|---|---|---|
| apps/api | 5 254 | 1 004 | ~45% |
| apps/web | 6 454 | 374 | ~10% |
| apps/worker | 986 | 230 | ~20% |
| packages | 2 853 | 2 162 | ~72% |
| Total | ~15 547 | ~3 770 | ~40% |
Hotspots identifies
Backend (P1)
| Fichier | LOC | Complexite | Probleme |
|---|---|---|---|
| ws-conversation-router.ts | 358 | Tres haute | Race condition persona locks, memory leak maps unbounded |
| ws-ollama.ts | 303 | Tres haute | Semaphore manuel, queue starvation, JSON streaming fragile |
| context-store.ts | 435 | Haute | RAM unbounded en compaction, deadlock potentiel |
| worker-runtime.ts | 564 | Tres haute | Subprocess timeout cascade, signal handling absent |
| app.ts | 538 | Moyenne | 7 repo factories inline, couplage fort |
Frontend (P1)
| Composant | LOC | Probleme |
|---|---|---|
| Chat.tsx | 631 | Monolithique, 10+ useState, getNickColor re-render |
| ChatHistory.tsx | 601 | Pagination complexe, pas de virtualisation |
| NodeEditor.tsx | 406 | Logique metier melee au rendu |
| VoiceChat.tsx | 388 | Memory leak recordingTimer, silenceTimer |
| ComposePage/ImaginePage | 203/185 | WS pattern duplique, progress bar simulee |
Packages (P2)
| Package | Probleme |
|---|---|
| @kxkm/core | createId race condition en worker threads |
| @kxkm/node-engine | Hyperparams sans validation bounds, docker image hardcoded |
| @kxkm/persona-domain | Extra keys non types, DPO pairs silent [] |
| @kxkm/storage | Types unsafe sur row mapping (pas de zod) |
| @kxkm/ui | Zero tests |
Vulnerabilites securite
| # | Severite | Fichier | Description |
|---|---|---|---|
| SEC-01 | CRITICAL | app-middleware.ts | Cookie session sans Secure flag (HTTPS) |
| SEC-02 | HIGH | routes/session.ts | Admin token plaintext en env vars |
| SEC-03 | MEDIUM | ws-upload-handler.ts | MIME type validation contournable (header, pas magic bytes) |
| SEC-04 | MEDIUM | /api/session/login | Pas de rate limiting (brute force) |
| SEC-05 | LOW | ws-ollama.ts | Tool execution sans whitelist / sandbox inputs |
Refactoring prioritaire
Tier 1 — Immediat
- Secure flag cookie (5 min) — app-middleware.ts
- Rate limit login (1h) — routes/session.ts
- MIME magic bytes validation (30 min) — ws-upload-handler.ts, lib
file-type - VoiceChat timer cleanup (30 min) — recordingTimerRef + silenceTimerRef
- Chat.tsx getNickColor useCallback (15 min) — reduire re-renders 50%
Tier 2 — Sprint suivant
- Decouper Chat.tsx en ChatMessages + ChatInput + ChatSidebar (2-3j)
- Remplacer semaphore manuel par p-limit dans ws-ollama.ts (1h)
- Input validation schemas (zod) sur endpoints API (4h)
- Storage row mapping runtime validation (4h)
- Tests Chat.tsx + VoiceChat.tsx (2j)
Tier 3 — Moyen terme
- Virtualisation chat messages (react-window)
- Worker strategy pattern pour node executors
- Error telemetry (Sentry ou equivalent)
- A11y pass WCAG 2.1 AA (labels, focus, contrast)
- Integration test suite end-to-end
Veille OSS — Nouvelles decouvertes mars 2026
| Projet | Pertinence | Notes |
|---|---|---|
| Qwen3-TTS (Alibaba) | P2 | 0.6B-1.7B, clone voix 3s, 10 langues, Apache 2.0 |
| Pocket TTS (Kyutai) | P3 | 100M params, CPU temps reel, voice cloning |
| NexusRAG | P3 | Hybrid: vector + LightRAG + Docling + Ollama |
| AgoraAI | P2 | Multi-persona voice-to-voice, dual-queue async |
| webgl-crt-shader | P3 | GPU-accelere, plus authentique que vault66 CSS |
| LightRAG v1.4.11rc2 | P1 | Releases actives, Ollama natif, workspace isolation |
Backlog mis a jour
Lot 15 (en cours) — 2/4 done
- persona-domain-seams
- node-engine-seams (registry.ts extrait)
- storage-test-split
- web-chat-modularization (Chat.tsx → seams)
Backlog Phase 7+
- Chatterbox TTS deploiement production (P1)
- LightRAG v1.4.11 integration (P1)
- Secure flag + rate limit login (P1 securite)
- Chat.tsx modularisation (lot 15)
- Tests couverture >60% (Chat, VoiceChat, ws-ollama)
- vault66 ou webgl-crt-shader (P3)
- AgoraAI etude architecture (P3)
- Qwen3-TTS evaluation (P2)