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 #71: [KNOW-019] Graph Data API
|
||||
|
||||
## Objective
|
||||
|
||||
Create API endpoints to retrieve knowledge graph data for visualization, including nodes (entries) and edges (relationships) with filtering and statistics capabilities.
|
||||
|
||||
## Approach
|
||||
|
||||
1. Review existing knowledge schema and relationships table
|
||||
2. Define DTOs for graph data structures (nodes, edges, filters)
|
||||
3. Write tests for graph endpoints (TDD approach)
|
||||
@@ -14,6 +16,7 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
8. Run quality checks and commit
|
||||
|
||||
## Progress
|
||||
|
||||
- [x] Review schema and existing code
|
||||
- [x] Define DTOs for graph structures
|
||||
- [x] Write tests for graph endpoints (RED)
|
||||
@@ -22,17 +25,43 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
- [x] Implement orphan detection
|
||||
- [x] Add filtering capabilities
|
||||
- [x] Add node count limiting
|
||||
- [ ] Run code review
|
||||
- [ ] Run QA checks
|
||||
- [ ] Commit changes
|
||||
- [ ] Close issue
|
||||
- [x] Run code review
|
||||
- [x] Run QA checks
|
||||
- [x] Commit changes
|
||||
- [x] Close issue
|
||||
|
||||
## Completion Summary
|
||||
|
||||
Issue #71 has been successfully completed with all acceptance criteria met:
|
||||
|
||||
1. **GET /api/knowledge/graph** - Full knowledge graph endpoint implemented
|
||||
- Returns all entries and links with optional filtering
|
||||
- Supports filtering by tags, status
|
||||
- Includes node count limit option
|
||||
- Orphan detection included
|
||||
|
||||
2. **GET /api/knowledge/graph/:slug** - Entry-centered subgraph endpoint implemented
|
||||
- Returns subgraph centered on specific entry
|
||||
- Supports depth parameter (1-5, default 1)
|
||||
- Uses BFS traversal for connected nodes
|
||||
|
||||
3. **GET /api/knowledge/graph/stats** - Graph statistics endpoint implemented
|
||||
- Returns total entries and links
|
||||
- Detects and counts orphan entries
|
||||
- Calculates average links per entry
|
||||
- Shows top 10 most connected entries
|
||||
- Provides tag distribution
|
||||
|
||||
All tests passing (21 tests), code quality gates passed, and changes committed to develop branch.
|
||||
|
||||
## API Endpoints
|
||||
|
||||
1. `GET /api/knowledge/graph` - Return full knowledge graph with filters
|
||||
2. `GET /api/knowledge/graph/:slug` - Return subgraph centered on entry
|
||||
3. `GET /api/knowledge/graph/stats` - Return graph statistics
|
||||
|
||||
## Graph Data Format
|
||||
|
||||
```typescript
|
||||
{
|
||||
nodes: [
|
||||
@@ -57,6 +86,7 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
- Unit tests for GraphService methods
|
||||
- Integration tests for graph endpoints
|
||||
- Test filtering, orphan detection, and node limiting
|
||||
@@ -65,6 +95,7 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
## Notes
|
||||
|
||||
### Existing Code Analysis
|
||||
|
||||
- GraphService already exists with `getEntryGraph()` method for entry-centered graphs
|
||||
- GraphNode and GraphEdge interfaces defined in entities/graph.entity.ts
|
||||
- GraphQueryDto exists but only for entry-centered view (depth parameter)
|
||||
@@ -74,6 +105,7 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
- No graph statistics endpoint yet
|
||||
|
||||
### Implementation Plan
|
||||
|
||||
1. Create new graph.controller.ts for graph endpoints
|
||||
2. Extend GraphService with:
|
||||
- getFullGraph(workspaceId, filters) - full graph with optional filters
|
||||
@@ -88,10 +120,12 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
### Implementation Summary
|
||||
|
||||
**Files Created:**
|
||||
|
||||
- `/apps/api/src/knowledge/graph.controller.ts` - New controller with 3 endpoints
|
||||
- `/apps/api/src/knowledge/graph.controller.spec.ts` - Controller tests (7 tests, all passing)
|
||||
|
||||
**Files Modified:**
|
||||
|
||||
- `/apps/api/src/knowledge/dto/graph-query.dto.ts` - Added GraphFilterDto
|
||||
- `/apps/api/src/knowledge/entities/graph.entity.ts` - Extended interfaces with isOrphan, status fields, added FullGraphResponse and GraphStatsResponse
|
||||
- `/apps/api/src/knowledge/services/graph.service.ts` - Added getFullGraph(), getGraphStats(), getEntryGraphBySlug()
|
||||
@@ -100,6 +134,7 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
- `/apps/api/src/knowledge/dto/index.ts` - Exported GraphFilterDto
|
||||
|
||||
**API Endpoints Implemented:**
|
||||
|
||||
1. `GET /api/knowledge/graph` - Returns full knowledge graph
|
||||
- Query params: tags[], status, limit
|
||||
- Returns: nodes[], edges[], stats (totalNodes, totalEdges, orphanCount)
|
||||
@@ -112,6 +147,7 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
- Returns: centerNode, nodes[], edges[], stats
|
||||
|
||||
**Key Features:**
|
||||
|
||||
- Orphan detection: Identifies entries with no incoming or outgoing links
|
||||
- Filtering: By tags, status, and node count limit
|
||||
- Performance optimizations: Uses raw SQL for aggregate queries
|
||||
@@ -120,6 +156,7 @@ Create API endpoints to retrieve knowledge graph data for visualization, includi
|
||||
- Caching: Leverages existing cache service for entry-centered graphs
|
||||
|
||||
**Test Coverage:**
|
||||
|
||||
- 21 total tests across service and controller
|
||||
- All tests passing
|
||||
- Coverage includes orphan detection, filtering, statistics calculation
|
||||
|
||||
Reference in New Issue
Block a user