Implements FED-010: Agent Spawn via Federation feature that enables spawning and managing Claude agents on remote federated Mosaic Stack instances via COMMAND message type. Features: - Federation agent command types (spawn, status, kill) - FederationAgentService for handling agent operations - Integration with orchestrator's agent spawner/lifecycle services - API endpoints for spawning, querying status, and killing agents - Full command routing through federation COMMAND infrastructure - Comprehensive test coverage (12/12 tests passing) Architecture: - Hub → Spoke: Spawn agents on remote instances - Command flow: FederationController → FederationAgentService → CommandService → Remote Orchestrator - Response handling: Remote orchestrator returns agent status/results - Security: Connection validation, signature verification Files created: - apps/api/src/federation/types/federation-agent.types.ts - apps/api/src/federation/federation-agent.service.ts - apps/api/src/federation/federation-agent.service.spec.ts Files modified: - apps/api/src/federation/command.service.ts (agent command routing) - apps/api/src/federation/federation.controller.ts (agent endpoints) - apps/api/src/federation/federation.module.ts (service registration) - apps/orchestrator/src/api/agents/agents.controller.ts (status endpoint) - apps/orchestrator/src/api/agents/agents.module.ts (lifecycle integration) Testing: - 12/12 tests passing for FederationAgentService - All command service tests passing - TypeScript compilation successful - Linting passed Refs #93 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2.5 KiB
2.5 KiB
Issue ORCH-113: Coordinator API client
Objective
Implement HTTP client for calling coordinator quality gates from orchestrator service.
Approach
- Create CoordinatorClientService in NestJS with proper dependency injection
- Use native fetch API for HTTP calls (Node.js 18+ built-in)
- Integrate with ConfigService for COORDINATOR_URL configuration
- Implement POST /api/quality/check endpoint call
- Add retry logic for coordinator unavailable scenarios
- Create comprehensive unit tests with mocked fetch
API Contract
POST /api/quality/check
Request: {
taskId: string,
agentId: string,
files: string[],
diffSummary: string
}
Response: {
approved: boolean,
gate: string,
message?: string,
details?: Record<string, unknown>
}
Progress
- Read requirements from M6-NEW-ISSUES-TEMPLATES.md
- Understand coordinator and orchestrator structure
- Identify coordinator is Python/FastAPI, orchestrator is NestJS
- Create scratchpad
- Add COORDINATOR_URL to orchestrator.config.ts
- Write failing tests for CoordinatorClientService (RED phase)
- Implement CoordinatorClientService (GREEN phase)
- Ensure ≥85% test coverage (96.61% statements, 90% branches, 100% lines)
- Update CoordinatorModule to export the service
- Update AppModule to import CoordinatorModule
- Verify TypeScript compilation succeeds for coordinator files
- 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