feat(#93): implement agent spawn via federation

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>
This commit is contained in:
Jason Woltje
2026-02-03 14:37:06 -06:00
parent a8c8af21e5
commit 12abdfe81d
405 changed files with 13545 additions and 2153 deletions

View File

@@ -1,9 +1,11 @@
# Issue #8: Docker Compose setup (turnkey)
## Objective
Create a complete turnkey Docker Compose setup that allows users to start the entire Mosaic Stack with a single command. The setup must include all necessary services with proper health checks, dependency ordering, and initialization.
## Approach
1. Create comprehensive docker-compose.yml with all services:
- PostgreSQL 17 + pgvector extension
- Valkey (Redis-compatible cache)
@@ -38,6 +40,7 @@ Create a complete turnkey Docker Compose setup that allows users to start the en
- CONFIGURATION.md - configuration options
## Progress
- [x] Create scratchpad (this file)
- [x] Examine current project structure
- [x] Design docker-compose.yml structure
@@ -61,12 +64,14 @@ Create a complete turnkey Docker Compose setup that allows users to start the en
## COMPLETION STATUS: READY FOR TESTING
All implementation work is complete. The Docker Compose setup is:
- ✓ Fully documented
- ✓ Comprehensively configured
- ✓ Test scripts ready
- ✓ Production-ready with security considerations
Next steps for deployment testing:
1. Run smoke test: `./scripts/test-docker-deployment.sh`
2. Run integration tests: `pnpm test:docker`
3. Manual validation of all service profiles
@@ -74,6 +79,7 @@ Next steps for deployment testing:
5. Security audit of default configurations
## Testing
- Integration tests for Docker stack startup
- Health check validation
- Service connectivity tests
@@ -81,6 +87,7 @@ Next steps for deployment testing:
- End-to-end deployment test
### Testing Commands
```bash
# Run integration tests
pnpm test:docker
@@ -97,6 +104,7 @@ docker compose down -v
```
### Manual Testing Checklist
- [x] docker-compose.yml syntax validation
- [x] All services defined with proper configuration
- [x] Health checks on all services
@@ -113,6 +121,7 @@ Note: Full deployment testing requires Docker environment.
The implementation is complete and ready for testing.
## Notes
- Must be truly turnkey - one command starts everything
- Support both bundled and external service configurations
- Follow project design principles (PDA-friendly)
@@ -122,6 +131,7 @@ The implementation is complete and ready for testing.
## Implementation Summary
### Files Created
1. **Docker Compose Files:**
- `/docker-compose.yml` - Main compose file with all services
- `/docker-compose.override.yml.example` - Template for customization
@@ -152,12 +162,14 @@ The implementation is complete and ready for testing.
### Services Implemented
**Core Services (Always Active):**
- PostgreSQL 17 with pgvector
- Valkey (Redis-compatible cache)
- Mosaic API (NestJS)
- Mosaic Web (Next.js)
**Optional Services (Profiles):**
- Authentik OIDC stack (profile: authentik)
- Authentik PostgreSQL
- Authentik Redis
@@ -166,6 +178,7 @@ The implementation is complete and ready for testing.
- Ollama AI (profile: ollama)
### Key Features
1. **Health Checks:** All services have proper health checks
2. **Dependency Ordering:** Services start in correct order
3. **Network Isolation:** Internal and public networks
@@ -176,7 +189,9 @@ The implementation is complete and ready for testing.
8. **Customization:** Override template for custom configs
### Environment Variables
Comprehensive `.env.example` includes:
- Application ports (API, Web)
- PostgreSQL configuration
- Valkey configuration
@@ -186,6 +201,7 @@ Comprehensive `.env.example` includes:
- Logging and debugging
### Testing Strategy
1. Integration tests for Docker stack
2. Health check validation
3. Service connectivity tests
@@ -193,6 +209,7 @@ Comprehensive `.env.example` includes:
5. Smoke test script for quick validation
### Documentation Coverage
- Quick start guide
- Complete deployment guide
- Configuration reference