# Issue ORCH-113: Coordinator API client ## Objective Implement HTTP client for calling coordinator quality gates from orchestrator service. ## Approach 1. Create CoordinatorClientService in NestJS with proper dependency injection 2. Use native fetch API for HTTP calls (Node.js 18+ built-in) 3. Integrate with ConfigService for COORDINATOR_URL configuration 4. Implement POST /api/quality/check endpoint call 5. Add retry logic for coordinator unavailable scenarios 6. Create comprehensive unit tests with mocked fetch ## API Contract ```typescript POST /api/quality/check Request: { taskId: string, agentId: string, files: string[], diffSummary: string } Response: { approved: boolean, gate: string, message?: string, details?: Record } ``` ## Progress - [x] Read requirements from M6-NEW-ISSUES-TEMPLATES.md - [x] Understand coordinator and orchestrator structure - [x] Identify coordinator is Python/FastAPI, orchestrator is NestJS - [x] Create scratchpad - [x] Add COORDINATOR_URL to orchestrator.config.ts - [x] Write failing tests for CoordinatorClientService (RED phase) - [x] Implement CoordinatorClientService (GREEN phase) - [x] Ensure ≥85% test coverage (96.61% statements, 90% branches, 100% lines) - [x] Update CoordinatorModule to export the service - [x] Update AppModule to import CoordinatorModule - [x] Verify TypeScript compilation succeeds for coordinator files - [x] Create Gitea issue #248 and close it ## Summary Successfully implemented ORCH-113 following strict TDD principles. The coordinator API client is fully functional with: - POST /api/quality/check endpoint integration - Retry logic with exponential backoff (3 attempts) - Comprehensive error handling - 96.61% statement coverage, 90% branch coverage, 100% line coverage - 15 passing unit tests - Full NestJS integration via CoordinatorModule The service is ready for use by ORCH-114 (Quality gate callbacks) and ORCH-115 (Task dispatch). ## Testing - Mock fetch for all HTTP calls - Test success scenario (approved=true) - Test rejection scenario (approved=false) - Test coordinator unavailable (connection error) - Test retry logic - Test invalid responses - Test timeout scenarios ## Notes - Coordinator runs on port 8000 (Python/FastAPI) - Orchestrator runs on port 3001 (NestJS) - Using native fetch API (available in Node 18+) - Retry strategy: 3 attempts with exponential backoff - ConfigService is already set up in app.module.ts - Need to extend orchestrator.config.ts with coordinatorUrl