veza/chat_exports/veza_ag_chat_7.md

401 lines
No EOL
10 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Chat Conversation
Note: _This is purely the output of the chat conversation and does not contain any raw data, codebase snippets, etc. used to generate the output._
### User Input
# 🚀 **PHASE 6 — FULL SYSTEM VALIDATION & PRE-RELEASE HARDENING**
Tu démarres maintenant **Phase 6**, aprÚs finalisation de :
* **API Contract Final (Phase 5)**
* **OpenAPI 3.1 complĂšte**
* **API Frontend Integration Guide**
* **API stability tests + micro-E2E API flow**
L’objectif est d’obtenir un projet **Veza Backend API** entiĂšrement prĂȘt pour :
* l’intĂ©gration complĂšte du frontend,
* la mise en staging,
* et la livraison d’une **Release Candidate (RC1)**.
Phase 6 consiste en une **validation transversale complùte**, au-delà de l’API :
services, repos, migrations, monitoring, jobs, cohérence transactionnelle, performance minimale, sécurité.
---
# 🎯 OBJECTIF GLOBAL PHASE 6
Garantir que **tout le backend est cohĂ©rent, performant, vĂ©rifiable, audit-proof**, et prĂȘt Ă  ĂȘtre gelĂ© pour une release RC1.
Phase 6 comprend :
1. **Full Contract Validation**
Vérifier que *chaque endpoint* implémenté respecte exactement :
* OpenAPI 3.1 (schémas, erreurs, enveloppes)
* API Contract Final (types, naming, constraints)
* API Frontend Guide (formes attendues cÎté client)
2. **Cross-Layer Consistency**
VĂ©rifier que tous les layers respectent l’API contract :
* handlers
* services
* repositories
* validators
* models
3. **System-Wide Regression Detection**
DĂ©celer toute incohĂ©rence introduite depuis Phase 1–5 :
* migrations manquantes / incohérentes
* sentinel errors non propagées correctement
* inconsistances transients (jobs schedulés, cleanup)
* performance dégradée sur certains services (bitrate adaptation, playlist ops)
4. **Security Hardening**
* Vérifier tout JWT, refresh, scopes, RBAC, forbidden cases
* S’assurer qu’aucune fuite d’existence (404 vs 403) n’existe
* Vérifier exhaustivement les path parameters (UUID validations)
* Vérifier upload / multipart security (DoS surfaces)
5. **Transaction & Consistency Review**
Inspecter :
* Playlist operations (multi-track reorder)
* Playback analytics batch operations
* Track upload + HLS generation interactions
* Cleanup jobs (session cleanup, token cleanup)
* Room & chat token lifecycle
6. **Performance Budget Check**
(Rapide mais indispensable)
* Latence handler ≀ 5ms local
* JSON parsing stable et sans allocations inutiles
* Repos SQLite tests ≀ 150ms
* Aucun handler n’effectue d’opĂ©ration O(NÂČ) inutile
7. **System-Level Tests & Acceptance Criteria**
Créer un pack de tests :
```
tests/system/
TestSystem_AuthAndRefresh
TestSystem_UploadAndTranscode
TestSystem_PlaylistAndTracks
TestSystem_Comments
TestSystem_RoomAndChatToken
TestSystem_AdminEndpoints
```
Ces tests utilisent SQLite + mocks pour services externes.
---
# ✔ **1. MISSION DÉTAILLÉE**
## A. VĂ©rification de conformitĂ© OpenAPI ↔ Code
Pour chaque endpoint :
* comparer handler ↔ DTO ↔ OpenAPI ↔ actual runtime
* détecter :
* champs en trop
* champs manquants
* valeurs incorrectes
* erreurs HTTP non conformes
* enveloppes JSON incorrectes
Produire un tableau :
```
Endpoint | Issue | Severity | Fix
```
## B. Validation JSON & Structs
Analyser tous les DTOs dans :
```
internal/dto/
internal/models/responses.go
internal/handlers/common.go
```
Objectifs :
* snake_case strict
* json tags cohérents
* aucun champ inutile exposé au client
* `omitempty` utilisé intelligemment
* structures uniformes dans toutes les réponses success/error
## C. Security Hardening Review
Inspecter :
* Refresh token logic
* Invalid token behavior
* Expired token behavior
* Missing/invalid scopes
* Playlist privacy leaks
* Chat token misuse
* Session hijacking protections
Corriger toute anomalie.
Un commit = un fix.
## D. Transaction & Consistency Review
Auditer :
* Playlist operations (add/remove/reorder)
* Track upload → session → HLS
* Comment parent/child correctness
* Room creation/join flows
* Playback analytics (intersections, aggregations, comparisons)
Ces couches doivent **toujours** respecter l’API Contract Final.
## E. Tests systĂšme
Créer le dossier :
```
tests/system/
```
Utiliser un runner dédié :
```
go test -v ./tests/system
```
Chaque test doit :
* exécuter un workflow complet
* vérifier la conformité JSON avec les schémas
* vérifier les codes HTTP corrects
* ĂȘtre indĂ©pendant (SQLite in-memory)
* ĂȘtre court et stable
## F. Mise Ă  jour des documents
Tu dois mettre Ă  jour :
* `API_CONTRACT_FINAL.md` (ajustements finaux)
* `API_FRONTEND_GUIDE.md` (exemples complets / correction)
* `API_STABILITY_REPORT.md`
* `POST_REMEDIATION_REPORT.md` (Phase 6)
* `CHANGELOG.md`
Et créer :
```
SYSTEM_VALIDATION_REPORT.md
SECURITY_REVIEW_FINAL.md
PERFORMANCE_BUDGET_REPORT.md
```
---
# ✔ **2. METHODOLOGIE EXÉCUTIVE**
### Étape 1
Scanner toute l’API (handlers/services/dto/models).
### Étape 2
Générer la liste exhaustive des incohérences.
### Étape 3
Proposer un ordre optimal de rĂ©solution P0 → P2.
### Étape 4
Appliquer les correctifs :
**1 commit = 1 problĂšme = 1 justification.**
### Étape 5
Exécuter les tests systÚme.
### Étape 6
Corriger jusqu’à obtenir **0 regression**.
### Étape 7
Produire les rapports finaux Phase 6.
---
# ✔ **3. DÉMARRAGE**
Commence maintenant en :
1. Scannant toutes les routes déclarées (cmd/api/main.go, router.go)
2. Comparant immĂ©diatement **OpenAPI ↔ handlers**
3. Produisant une liste P0/P1/P2
4. Appliquant le premier fix
---
# 🚀 **PHASE 6 STARTS NOW — CONTINUE**
*Edited relevant file*
*Edited relevant file*
*User accepted the command `find . -maxdepth 3 -not -path '*/.*'`*
*Viewed [swagger.yaml](file:///home/senke/Documents/veza/veza-backend-api/docs/swagger.yaml) *
*Viewed [router.go](file:///home/senke/Documents/veza/veza-backend-api/internal/api/router.go) *
*Viewed [swagger.json](file:///home/senke/Documents/veza/veza-backend-api/docs/swagger.json) *
*Viewed [API_CONTRACT_FINAL.md](file:///home/senke/Documents/veza/veza-backend-api/API_CONTRACT_FINAL.md) *
*Viewed [auth.go](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers/auth.go) *
*Searched filesystem*
*Viewed [common.go](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers/common.go) *
*Edited relevant file*
*Edited relevant file*
### User Input
*Viewed [main.go](file:///home/senke/Documents/veza/veza-backend-api/cmd/api/main.go) *
*Listed directory [dto](file:///home/senke/Documents/veza/veza-backend-api/internal/dto) *
*Viewed [login_request.go](file:///home/senke/Documents/veza/veza-backend-api/internal/dto/login_request.go) *
*Semantic searched codebase*
*Viewed [response.go](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers/response.go) *
*Viewed [register_request.go](file:///home/senke/Documents/veza/veza-backend-api/internal/dto/register_request.go) *
*Edited relevant file*
*Edited relevant file*
*Viewed [profile_handler.go](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers/profile_handler.go) *
*Edited relevant file*
*Edited relevant file*
*Edited relevant file*
*Listed directory [track](file:///home/senke/Documents/veza/veza-backend-api/internal/core/track) *
*Viewed [handler.go](file:///home/senke/Documents/veza/veza-backend-api/internal/core/track/handler.go) *
*Viewed [response.go](file:///home/senke/Documents/veza/veza-backend-api/internal/response/response.go) *
*Edited relevant file*
*Edited relevant file*
*Edited relevant file*
*Viewed [playlist_handler.go](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers/playlist_handler.go) *
*Edited relevant file*
*Edited relevant file*
*Viewed [chat_handler.go](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers/chat_handler.go) *
*Edited relevant file*
*Edited relevant file*
*Listed directory [handlers](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers) *
*Viewed [marketplace.go](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers/marketplace.go) *
*User accepted the command `swag init -g cmd/api/main.go --parseDependency --parseInternal`*
*User accepted the command `/home/senke/go/bin/swag init -g cmd/api/main.go --parseDependency --parseInternal`*
*Viewed [swagger.yaml](file:///home/senke/Documents/veza/veza-backend-api/docs/swagger.yaml) *
*Viewed [swagger.yaml](file:///home/senke/Documents/veza/veza-backend-api/docs/swagger.yaml) *
*Edited relevant file*
*Edited relevant file*
### User Input
commit ca
*User accepted the command `git status`*
*User accepted the command `git add . && git commit -m "feat(api): remediate missing openapi spec and annotate handlers"`*
*Edited relevant file*
*Edited relevant file*
*Edited relevant file*
*Edited relevant file*
*User accepted the command `go build ./internal/core/track/...`*
*Edited relevant file*
*User accepted the command `go build ./internal/core/track/...`*
*Edited relevant file*
*User accepted the command `git add . && git commit -m "refactor(track): enforce unified api response envelope"`*
*Edited relevant file*
*User accepted the command `go build ./internal/handlers/...`*
*Edited relevant file*
*Listed directory [errors](file:///home/senke/Documents/veza/veza-backend-api/internal/errors) *
*Viewed [errors.go](file:///home/senke/Documents/veza/veza-backend-api/internal/errors/errors.go) *
*Viewed [codes.go](file:///home/senke/Documents/veza/veza-backend-api/internal/errors/codes.go) *
*Edited relevant file*
*User accepted the command `go build ./internal/handlers/...`*
*Viewed [marketplace.go](file:///home/senke/Documents/veza/veza-backend-api/internal/handlers/marketplace.go) *
*User accepted the command `go build ./internal/handlers/...`*
*Edited relevant file*
*User accepted the command `go build ./internal/handlers/...`*
*User accepted the command `/home/senke/go/bin/swag init -g cmd/api/main.go --parseDependency --parseInternal`*
*Edited relevant file*
*Edited relevant file*
*User accepted the command `git add . && git commit -m "refactor(marketplace): enforce unified api response envelope"`*