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:
@@ -1,9 +1,11 @@
|
||||
# Issue #2: PostgreSQL 17 + pgvector Schema
|
||||
|
||||
## Objective
|
||||
|
||||
Design and implement the PostgreSQL 17 database schema with pgvector extension for Mosaic Stack.
|
||||
|
||||
## Approach
|
||||
|
||||
1. **Docker Infrastructure** - Build PostgreSQL 17 container with pgvector extension
|
||||
2. **Prisma ORM** - Define schema with 8 core models (User, Workspace, Task, Event, Project, etc.)
|
||||
3. **Multi-tenant Design** - All tables indexed by workspace_id for RLS preparation
|
||||
@@ -11,6 +13,7 @@ Design and implement the PostgreSQL 17 database schema with pgvector extension f
|
||||
5. **NestJS Integration** - PrismaService + EmbeddingsService for database operations
|
||||
|
||||
## Progress
|
||||
|
||||
- [x] Plan approved
|
||||
- [x] Phase 1: Docker Setup (5 tasks) - COMPLETED
|
||||
- [x] Phase 2: Prisma Schema (5 tasks) - COMPLETED
|
||||
@@ -19,9 +22,11 @@ Design and implement the PostgreSQL 17 database schema with pgvector extension f
|
||||
- [x] Phase 5: Build & Verification (2 tasks) - COMPLETED
|
||||
|
||||
## Completion Summary
|
||||
|
||||
**Issue #2 successfully completed on 2026-01-28**
|
||||
|
||||
### What Was Delivered
|
||||
|
||||
1. **Docker Infrastructure**
|
||||
- PostgreSQL 17 with pgvector v0.7.4 (HNSW index enabled)
|
||||
- Valkey for caching
|
||||
@@ -54,19 +59,23 @@ Design and implement the PostgreSQL 17 database schema with pgvector extension f
|
||||
- All builds passing with strict TypeScript
|
||||
|
||||
### Database Statistics
|
||||
|
||||
- Tables: 8
|
||||
- Extensions: uuid-ossp, vector (pgvector 0.7.4)
|
||||
- Indexes: 14 total (including 1 HNSW vector index)
|
||||
- Seed data: 1 user, 1 workspace, 1 project, 5 tasks, 1 event
|
||||
|
||||
## Testing
|
||||
|
||||
- Unit tests for PrismaService (connection lifecycle, health check)
|
||||
- Unit tests for EmbeddingsService (store, search, delete operations)
|
||||
- Integration test with actual PostgreSQL database
|
||||
- Seed data validation via Prisma Studio
|
||||
|
||||
## Notes
|
||||
|
||||
### Design Decisions
|
||||
|
||||
- **UUID primary keys** for multi-tenant scalability
|
||||
- **Native Prisma enums** mapped to PostgreSQL enums for type safety
|
||||
- **`Unsupported("vector(1536)")`** type for pgvector (raw SQL operations)
|
||||
@@ -74,11 +83,13 @@ Design and implement the PostgreSQL 17 database schema with pgvector extension f
|
||||
- **Self-referencing Task** model for subtasks support
|
||||
|
||||
### Key Relations
|
||||
|
||||
- User → ownedWorkspaces (1:N), workspaceMemberships (N:M via WorkspaceMember)
|
||||
- Workspace → tasks, events, projects, activityLogs, memoryEmbeddings (1:N each)
|
||||
- Task → subtasks (self-referencing), project (optional N:1)
|
||||
|
||||
### RLS Preparation (M2 Milestone)
|
||||
|
||||
- All tenant tables have workspace_id with index
|
||||
- Future: PostgreSQL session variables (app.current_workspace_id, app.current_user_id)
|
||||
- Future: RLS policies for workspace isolation
|
||||
|
||||
Reference in New Issue
Block a user