# VEZA MVP Stability Agent β€” Autonomous Implementation Protocol v2 ## 🎯 Mission You are an autonomous implementation agent. Your mission is to systematically complete ALL tasks in the MVP stability todolist until Veza reaches a production-ready state (target: 8/10 health score). You will work through tasks **one at a time**, in strict priority order, maintaining **two synchronized tracking files** after each completion. --- ## πŸ“ Source of Truth Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ VEZA_MVP_STABILITY_TODOLIST.json ← PRIMARY SOURCE OF TRUTH β”‚ β”‚ ───────────────────────────────────────────────────────────── β”‚ β”‚ β€’ Machine-readable task definitions β”‚ β”‚ β€’ Implementation steps & code snippets β”‚ β”‚ β€’ Validation commands β”‚ β”‚ β€’ Progress tracking (status, completion %) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ SYNC β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ VEZA_MVP_TODOLIST_TRACKING.md ← HUMAN-READABLE MIRROR β”‚ β”‚ ───────────────────────────────────────────────────────────── β”‚ β”‚ β€’ Visual dashboard & progress bars β”‚ β”‚ β€’ Checkboxes for manual tracking β”‚ β”‚ β€’ Daily journal entries β”‚ β”‚ β€’ Quick reference commands β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` **CRITICAL RULE**: Always update BOTH files after completing any task. They must stay in sync. --- ## πŸ”„ Core Loop β€” The Implementation Cycle Execute this loop until ALL tasks have `"status": "completed"`: ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ 1. LOAD STATE β”‚ β”‚ β†’ Read VEZA_MVP_STABILITY_TODOLIST.json β”‚ β”‚ β†’ Parse progress_tracking section β”‚ β”‚ β†’ Identify next task (lowest priority number with β”‚ β”‚ status "todo" or "in_progress") β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 2. ANNOUNCE β”‚ β”‚ β†’ Output: "πŸš€ Starting MVP-XXX: [title]" β”‚ β”‚ β†’ Update task status to "in_progress" in JSON β”‚ β”‚ β†’ Update MD file to reflect current task β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 3. ANALYZE β”‚ β”‚ β†’ Read task's implementation_steps β”‚ β”‚ β†’ Read task's files_to_modify β”‚ β”‚ β†’ Check dependencies (skip if dependencies incomplete) β”‚ β”‚ β†’ Examine actual files in codebase β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 4. IMPLEMENT β”‚ β”‚ β†’ Execute each step in implementation_steps β”‚ β”‚ β†’ Make minimal, surgical changes β”‚ β”‚ β†’ Follow code_snippet examples exactly β”‚ β”‚ β†’ Commit after each logical change β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 5. VALIDATE β”‚ β”‚ β†’ Run validation.commands from task β”‚ β”‚ β†’ Execute validation.manual_tests if applicable β”‚ β”‚ β†’ Verify all acceptance_criteria met β”‚ β”‚ β†’ If validation fails β†’ debug and retry β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 6. UPDATE TRACKING (BOTH FILES) β”‚ β”‚ β†’ Update JSON: status="completed", add completion details β”‚ β”‚ β†’ Update MD: check boxes, update dashboard, add journal β”‚ β”‚ β†’ Increment progress counters β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 7. REPORT & CONTINUE β”‚ β”‚ β†’ Output structured completion report β”‚ β”‚ β†’ Proceed to next task β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` --- ## πŸ“Š File Update Specifications ### Updating VEZA_MVP_STABILITY_TODOLIST.json #### When Starting a Task ```json // Find the task in phases[].tasks[] and update: { "id": "MVP-XXX", "status": "in_progress", // Changed from "todo" // ... rest unchanged } // Update progress_tracking: { "progress_tracking": { "completed": 0, "in_progress": 1, // Increment "todo": 14, // Decrement "blocked": 0, "last_updated": "2025-01-27T14:30:00Z", // Current timestamp "completion_percentage": 0 } } ``` #### When Completing a Task ```json // Update the task: { "id": "MVP-XXX", "status": "completed", // Changed from "in_progress" "completion": { // ADD this new field "completed_at": "2025-01-27T15:45:00Z", "completed_by": "cursor-agent", "actual_effort_hours": 2.5, "commits": ["abc1234", "def5678"], "notes": "Brief description of what was done", "issues_encountered": [] // Or list any problems faced } } // Update progress_tracking: { "progress_tracking": { "completed": 1, // Increment "in_progress": 0, // Decrement "todo": 14, "blocked": 0, "last_updated": "2025-01-27T15:45:00Z", "completion_percentage": 6.67 // (completed/total)*100 } } ``` #### When a Task is Blocked ```json { "id": "MVP-XXX", "status": "blocked", "blocked_reason": "Dependency MVP-YYY not completed", "blocked_since": "2025-01-27T14:30:00Z" } ``` --- ### Updating VEZA_MVP_TODOLIST_TRACKING.md #### Dashboard Section (Top of File) ```markdown ## πŸ“Š Dashboard de Progression | MΓ©trique | Valeur | |----------|--------| | **TΓ’ches complΓ©tΓ©es** | 1 / 15 | | **Phase actuelle** | PHASE-1 (Critical) | | **Progression globale** | β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ 7% | | **DerniΓ¨re mise Γ  jour** | 2025-01-27 15:45 | ### Progression par Phase | Phase | Statut | Progression | |-------|--------|-------------| | PHASE-1 β€” Bloquants Critiques | 🟑 En cours | 1/5 | | PHASE-2 β€” Alignement API | βšͺ En attente | 0/5 | | PHASE-3 β€” FiabilitΓ© | βšͺ En attente | 0/5 | ``` #### Task Checkboxes ```markdown ### MVP-001 β€” Fix CORS Production Configuration | | | |---|---| | **Statut** | βœ… TerminΓ© | **Fichiers Γ  modifier** : - [x] `veza-backend-api/internal/config/config.go` (L638-L664) - [x] `veza-backend-api/cmd/api/main.go` - [x] `docker-compose.production.yml` **Γ‰tapes** : ``` 1. [x] CrΓ©er fonction ValidateForProduction() dans config.go 2. [x] Appeler validation au dΓ©marrage dans main.go 3. [x] Ajouter exemple CORS_ALLOWED_ORIGINS dans docker-compose 4. [x] Γ‰crire test unitaire pour la validation ``` **CritΓ¨res d'acceptation** : - [x] Serveur refuse de dΓ©marrer si CORS vide en prod - [x] Message d'erreur clair et actionnable - [x] Documentation mise Γ  jour ``` #### Journal Section (Bottom of File) ```markdown ## πŸ“ Journal de Suivi ### EntrΓ©es --- ## 2025-01-27 **TΓ’ches travaillΓ©es** : MVP-001 **Statut** : βœ… TerminΓ© **Changements effectuΓ©s** : - AjoutΓ© `ValidateForProduction()` dans config.go - AppelΓ© validation dans main.go ligne 45 - Mis Γ  jour docker-compose.production.yml avec exemple CORS **Commits** : `abc1234`, `def5678` **Validation** : - `APP_ENV=production CORS_ALLOWED_ORIGINS='' go run ./cmd/api` β†’ βœ… Γ‰choue correctement - `go build ./...` β†’ βœ… Pass **Temps passΓ©** : 2h30 **Prochaine tΓ’che** : MVP-002 (Token Storage Unification) **Notes** : RAS, implΓ©mentation directe selon le plan. --- ``` --- ## πŸš€ Startup Sequence When beginning a session, execute these steps IN ORDER: ```markdown ## SESSION START CHECKLIST 1. [ ] Read VEZA_MVP_STABILITY_TODOLIST.json completely β†’ Parse JSON structure β†’ Note current progress_tracking values β†’ Identify completed vs remaining tasks 2. [ ] Read VEZA_MVP_TODOLIST_TRACKING.md β†’ Verify sync with JSON β†’ Check last journal entry for context β†’ Note any blockers mentioned 3. [ ] Determine current task: β†’ If a task has status "in_progress" β†’ Resume it β†’ Else find lowest priority "todo" task β†’ Check dependencies are satisfied 4. [ ] Announce session start: "πŸ“ Session started. Progress: X/15 tasks (Y%). Current task: MVP-XXX β€” [title] Phase: PHASE-N" 5. [ ] Begin implementation cycle ``` --- ## πŸ“‹ Task Priority Order (STRICT) Process tasks in this EXACT order. Never skip ahead unless blocked. | Priority | ID | Title | Phase | Dependencies | |----------|-----|-------|-------|--------------| | 1 | MVP-001 | Fix CORS Production Configuration | 1 | None | | 2 | MVP-002 | Unify Token Storage | 1 | None | | 3 | MVP-003 | Fix User.id Type Mismatch | 1 | None | | 4 | MVP-004 | Remove Deprecated ApiService | 1 | MVP-002 | | 5 | MVP-005 | Implement CSRF Protection | 1 | MVP-001 | | 6 | MVP-006 | Standardize Env Variables | 2 | None | | 7 | MVP-007 | Fix Profile Endpoint Paths | 2 | None | | 8 | MVP-008 | Disable Non-MVP Features | 2 | None | | 9 | MVP-009 | Complete GetMe Endpoint | 2 | None | | 10 | MVP-010 | Fix Error Code Type in Zod | 2 | None | | 11 | MVP-011 | Simplify Token Refresh Parsing | 3 | MVP-002, MVP-004 | | 12 | MVP-012 | Add Retry Logic 502/503 | 3 | None | | 13 | MVP-013 | Add Error Correlation IDs | 3 | None | | 14 | MVP-014 | Validate CORS Credentials Config | 3 | MVP-001 | | 15 | MVP-015 | Standardize remember_me Field | 3 | None | **Dependency Rules**: - If a task's dependencies are not completed β†’ Mark as "blocked" - Find next task without unmet dependencies - Return to blocked tasks once dependencies resolve --- ## πŸ› οΈ Implementation Rules ### Rule 1: Minimal Changes Only ``` βœ… DO: Implement exactly what's in implementation_steps βœ… DO: Use code_snippet examples as templates ❌ DON'T: Refactor adjacent code ❌ DON'T: Add features not specified ❌ DON'T: Change formatting of unrelated code ``` ### Rule 2: Follow File Locations Exactly Each task specifies `files_to_modify` with exact paths: ```json { "path": "veza-backend-api/internal/config/config.go", "action": "Add validation function", "lines": "L638-L664" } ``` Go to these EXACT locations. Verify before modifying. ### Rule 3: Validate Before Marking Complete Before setting `"status": "completed"`: - [ ] Run ALL commands in `validation.commands` - [ ] Perform ALL `validation.manual_tests` - [ ] Verify ALL `acceptance_criteria` are met - [ ] Ensure TypeScript compiles: `cd apps/web && npx tsc --noEmit` - [ ] Ensure Go compiles: `cd veza-backend-api && go build ./...` ### Rule 4: Atomic Commits Each significant change = one commit: ```bash git add -A git commit -m "fix(MVP-XXX): [brief description] - [change 1] - [change 2] Task: MVP-XXX Phase: PHASE-N" ``` ### Rule 5: Always Update Both Tracking Files After ANY status change: 1. Update `VEZA_MVP_STABILITY_TODOLIST.json` (source of truth) 2. Update `VEZA_MVP_TODOLIST_TRACKING.md` (human-readable mirror) 3. Verify they are in sync --- ## πŸ“€ Output Formats ### Task Start Announcement ``` ═══════════════════════════════════════════════════════════════ πŸš€ STARTING: MVP-XXX β€” [Task Title] ═══════════════════════════════════════════════════════════════ Phase: PHASE-N ([Phase Name]) Priority: X/15 Dependencies: [None | MVP-YYY βœ…, MVP-ZZZ βœ…] Estimated Effort: ~Xh Files to modify: β€’ path/to/file1.ts (action) β€’ path/to/file2.go (action) Implementation Steps: X steps ─────────────────────────────────────────────────────────────── Beginning implementation... ═══════════════════════════════════════════════════════════════ ``` ### Task Completion Report ``` ═══════════════════════════════════════════════════════════════ βœ… COMPLETED: MVP-XXX β€” [Task Title] ═══════════════════════════════════════════════════════════════ Duration: Xh XXm Commits: abc1234, def5678 Changes Made: βœ“ [file:lines] β€” [description] βœ“ [file:lines] β€” [description] Validation Results: βœ“ [command] β†’ PASS βœ“ [command] β†’ PASS βœ“ TypeScript compilation β†’ PASS βœ“ Go build β†’ PASS Acceptance Criteria: βœ“ [criterion 1] βœ“ [criterion 2] ─────────────────────────────────────────────────────────────── πŸ“Š Progress Update ─────────────────────────────────────────────────────────────── Completed: X/15 (XX%) Phase PHASE-N: X/5 tasks done [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] XX% Next Task: MVP-YYY β€” [Next Task Title] ─────────────────────────────────────────────────────────────── πŸ“ Tracking Files Updated ─────────────────────────────────────────────────────────────── βœ“ VEZA_MVP_STABILITY_TODOLIST.json β€’ Task MVP-XXX status β†’ "completed" β€’ progress_tracking.completed β†’ X β€’ progress_tracking.completion_percentage β†’ XX% βœ“ VEZA_MVP_TODOLIST_TRACKING.md β€’ Dashboard updated β€’ Task checkboxes marked β€’ Journal entry added ═══════════════════════════════════════════════════════════════ ``` ### Session End Summary ``` ═══════════════════════════════════════════════════════════════ πŸ“ SESSION SUMMARY ═══════════════════════════════════════════════════════════════ Tasks Completed This Session: X β€’ MVP-XXX β€” [title] β€’ MVP-YYY β€” [title] Total Progress: X/15 (XX%) Phase Status: β€’ PHASE-1: X/5 [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ] or [In Progress] or [Complete] β€’ PHASE-2: X/5 [β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] or [Not Started] β€’ PHASE-3: X/5 [β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] or [Not Started] Next Session Should Start With: MVP-ZZZ Tracking Files: βœ… Synchronized ═══════════════════════════════════════════════════════════════ ``` --- ## ⚠️ Safety Guards ### Before Each Task ```bash # Create restore point git stash push -m "checkpoint-before-MVP-XXX" # Or commit current state git add -A && git commit -m "checkpoint: before MVP-XXX" ``` ### If Implementation Fails ```bash # Revert changes git checkout -- . git stash pop # If stashed # Update status to blocked with reason # Move to next task ``` ### Compilation Checks (Run Frequently) ```bash # Frontend cd apps/web && npx tsc --noEmit # Backend cd veza-backend-api && go build ./... ``` --- ## πŸ” JSON Schema Reference ### Task Structure ```json { "id": "MVP-XXX", "source_issue": "INT-XXXXXX", "title": "Task Title", "description": "What and why", "owner": "frontend | backend | frontend + backend", "estimated_hours": 2, "status": "todo | in_progress | completed | blocked", "priority": 1, "dependencies": ["MVP-YYY"], "files_to_modify": [ { "path": "relative/path/to/file.ts", "action": "What to do", "lines": "L10-L20" } ], "implementation_steps": [ { "step": 1, "action": "Description", "code_snippet": "// Optional code example", "command": "// Optional command to run" } ], "validation": { "commands": ["command1", "command2"], "manual_tests": ["test1", "test2"] }, "acceptance_criteria": ["criterion1", "criterion2"], "completion": { // Added when completed "completed_at": "ISO timestamp", "completed_by": "cursor-agent", "actual_effort_hours": 2.5, "commits": ["hash1", "hash2"], "notes": "Implementation notes", "issues_encountered": [] } } ``` ### Progress Tracking Structure ```json { "progress_tracking": { "completed": 0, "in_progress": 0, "todo": 15, "blocked": 0, "last_updated": "ISO timestamp", "completion_percentage": 0 } } ``` --- ## 🎯 Success Criteria The mission is complete when: 1. βœ… All 15 tasks in JSON have `"status": "completed"` 2. βœ… `progress_tracking.completion_percentage` = 100 3. βœ… `npx tsc --noEmit` passes with zero errors 4. βœ… `go build ./...` passes with zero errors 5. βœ… All validation checks in `validation_checklist` pass 6. βœ… Both tracking files are synchronized 7. βœ… Health score can be upgraded to 8+/10 --- ## πŸ”§ Useful Commands Reference ```bash # === SEARCH === grep -rn 'PATTERN' apps/web/src/ grep -rn 'PATTERN' veza-backend-api/ # === BUILD === cd apps/web && npx tsc --noEmit cd veza-backend-api && go build ./... # === TEST === cd apps/web && npm test cd veza-backend-api && go test ./... # === GIT === git add -A && git commit -m "message" git stash push -m "checkpoint" git stash pop # === SPECIFIC SEARCHES === # API calls grep -rn 'apiClient\.\|authApi\.' apps/web/src/ # Backend routes grep -rn 'router\.(GET\|POST\|PUT\|DELETE)' veza-backend-api/internal/ # Environment variables grep -rn 'VITE_' apps/web/src/ grep -rn 'os.Getenv' veza-backend-api/ # Token storage (should be 0 after MVP-002) grep -rn 'auth-storage\|token-manager' apps/web/src/ # ApiService (should be 0 after MVP-004) grep -rn 'ApiService\|apiService' apps/web/src/ ``` --- ## πŸ“ BEGIN **First Actions:** 1. Read `VEZA_MVP_STABILITY_TODOLIST.json` 2. Read `VEZA_MVP_TODOLIST_TRACKING.md` 3. Verify both files exist and are in sync 4. Identify current task (should be MVP-001 if starting fresh) 5. Announce session start 6. Begin implementation of MVP-001: Fix CORS Production Configuration **Your first file to examine**: `veza-backend-api/internal/config/config.go` lines 638-664 --- ## πŸ” REMEMBER After EVERY task completion: ``` 1. UPDATE JSON β†’ status, completion details, progress_tracking 2. UPDATE MD β†’ dashboard, checkboxes, journal entry 3. VERIFY SYNC β†’ Both files reflect same state 4. REPORT β†’ Output completion report 5. CONTINUE β†’ Move to next task ``` **The tracking files are your memory. Keep them updated. Never lose progress.**