mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
Initial implementation
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
# TASK-001: Phase 1 - Core Services
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 1 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint:
|
||||
- Database schema
|
||||
- Messaging API
|
||||
- Agent framework
|
||||
- Infrastructure setup
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Database schema designed and implemented
|
||||
- [x] Messaging API (REST) functional
|
||||
- [x] Agent base class created
|
||||
- [x] Simple orchestrator built
|
||||
- [x] PostgreSQL configured
|
||||
- [x] Redis configured
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Project Configuration
|
||||
- `pyproject.toml` - Dependencies, ruff, mypy, pytest config
|
||||
- `docker-compose.yml` - PostgreSQL, Redis, Qdrant
|
||||
- `.env.example` - Environment template
|
||||
- `alembic/` - Migration setup
|
||||
|
||||
### 2. Data Models (`src/roboco/models/`)
|
||||
| File | Models |
|
||||
|------|--------|
|
||||
| `base.py` | All enums (TaskStatus, AgentRole, Team, etc.) |
|
||||
| `task.py` | Task, TaskPlan, Checkpoint, CommitRef |
|
||||
| `agent.py` | Agent, ModelConfig, AgentPermissions |
|
||||
| `session.py` | Session, SessionConfig |
|
||||
| `message.py` | ExtractedMessage, RawStream |
|
||||
| `group.py` | Group |
|
||||
| `channel.py` | Channel |
|
||||
| `notification.py` | Notification |
|
||||
| `journal.py` | Journal, JournalEntry |
|
||||
| `handoff.py` | DocumenterHandoff |
|
||||
|
||||
### 3. Database Layer (`src/roboco/db/`)
|
||||
- `base.py` - Async SQLAlchemy engine, session factory
|
||||
- `tables.py` - All ORM table definitions (10 tables)
|
||||
|
||||
### 4. Configuration (`src/roboco/config.py`)
|
||||
- Environment-based settings via pydantic-settings
|
||||
- Database, Redis, Qdrant, LLM provider configs
|
||||
|
||||
### 5. Messaging API (`src/roboco/api/`)
|
||||
| Route | Endpoints |
|
||||
|-------|-----------|
|
||||
| `health.py` | `/health`, `/ready` |
|
||||
| `channels.py` | CRUD for channels, member management |
|
||||
| `sessions.py` | Session lifecycle |
|
||||
| `messages.py` | Send, edit, delete messages |
|
||||
| `notifications.py` | Send, list, acknowledge |
|
||||
|
||||
### 6. WebSocket (`src/roboco/api/websocket.py`)
|
||||
- `/ws/channels/{id}` - Channel stream
|
||||
- `/ws/agents/{id}` - Agent output stream
|
||||
- `/ws/sessions/{id}` - Session stream
|
||||
- ConnectionManager for broadcasting
|
||||
|
||||
### 7. Agent Framework (`src/roboco/agents/`)
|
||||
- `base.py` - Agent base class with lifecycle, LLM stubs
|
||||
- `orchestrator.py` - Spawn/stop agents, health monitoring
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/
|
||||
├── __init__.py
|
||||
├── config.py
|
||||
├── models/
|
||||
│ ├── __init__.py
|
||||
│ ├── base.py, task.py, agent.py, session.py
|
||||
│ ├── message.py, group.py, channel.py
|
||||
│ ├── notification.py, journal.py, handoff.py
|
||||
│ └── README.md
|
||||
├── db/
|
||||
│ ├── __init__.py
|
||||
│ ├── base.py
|
||||
│ └── tables.py
|
||||
├── api/
|
||||
│ ├── __init__.py
|
||||
│ ├── app.py
|
||||
│ ├── deps.py
|
||||
│ ├── websocket.py
|
||||
│ └── routes/
|
||||
│ ├── __init__.py
|
||||
│ ├── health.py
|
||||
│ ├── channels.py
|
||||
│ ├── sessions.py
|
||||
│ ├── messages.py
|
||||
│ └── notifications.py
|
||||
└── agents/
|
||||
├── __init__.py
|
||||
├── base.py
|
||||
└── orchestrator.py
|
||||
```
|
||||
|
||||
## Next Steps (Phase 2: Communication)
|
||||
Per HOMELAB_TEAM_V0.md section 13.4:
|
||||
- [ ] Transcription service (extract messages from LLM streams)
|
||||
- [ ] Message extraction pipeline
|
||||
- [ ] Permission system
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 1 core services complete. Database schema, Messaging API, and Agent framework are functional. WebSocket streaming is in place. Ready for Phase 2 which adds transcription/extraction pipelines to process agent LLM output into structured messages.
|
||||
@@ -0,0 +1,119 @@
|
||||
# TASK-001: Phase 2 - Communication Services
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 2 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.4):
|
||||
- Transcription service (process LLM stream output)
|
||||
- Message extraction pipeline (identify message types)
|
||||
- Permission system (communication matrix enforcement)
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Transcription service buffers LLM stream chunks
|
||||
- [x] Extraction pipeline classifies messages (reasoning, dialogue, decision, action, blocker, technical)
|
||||
- [x] Permission service enforces channel read/write access
|
||||
- [x] Permission service enforces notification permissions
|
||||
- [x] Permission service enforces communication matrix
|
||||
- [x] API routes for stream processing
|
||||
- [x] API routes for permission checks
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Transcription Service (`src/roboco/services/transcription.py`)
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `StreamBuffer` | Accumulates chunks from agent, tracks timing, detects readiness |
|
||||
| `TranscriptionConfig` | Configurable thresholds (min chars, max chars, idle timeout) |
|
||||
| `TranscriptionService` | Main service with lifecycle, buffering, periodic flush |
|
||||
|
||||
Key features:
|
||||
- Buffers raw LLM output by agent/session
|
||||
- Detects segment boundaries (sentences, pauses, max length)
|
||||
- Background task for periodic buffer checking
|
||||
- Callback registration for ready segments
|
||||
|
||||
### 2. Extraction Service (`src/roboco/services/extraction.py`)
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| Pattern matchers | Regex patterns for each MessageType |
|
||||
| `ExtractionResult` | Container for extracted messages with metadata |
|
||||
| `ExtractionConfig` | Configurable extraction settings |
|
||||
| `ExtractionService` | Pattern-based message classification |
|
||||
| `ExtractionPipeline` | End-to-end processing with callbacks |
|
||||
|
||||
Message types detected:
|
||||
- **REASONING**: "I'm thinking...", "Let me analyze..."
|
||||
- **DIALOGUE**: Questions, @mentions, conversations
|
||||
- **DECISION**: "I've decided...", "Going with..."
|
||||
- **ACTION**: "Starting...", "Committing...", "Done:"
|
||||
- **BLOCKER**: "Blocked:", "Waiting on...", "Error:"
|
||||
- **TECHNICAL**: Code blocks, API explanations
|
||||
|
||||
### 3. Permission Service (`src/roboco/services/permissions.py`)
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `PermissionLevel` | Hierarchy levels (CEO → Board → Main PM → Cell PM → Member) |
|
||||
| `ChannelPermission` | Defines read/write access per channel |
|
||||
| `COMMUNICATION_MATRIX` | Who can communicate with whom |
|
||||
| `NOTIFICATION_TARGETS` | Who can notify whom |
|
||||
| `TASK_PERMISSIONS` | Task actions by role |
|
||||
| `PermissionService` | Main service for all permission checks |
|
||||
|
||||
Channel permissions implemented:
|
||||
- Cell channels (backend-cell, frontend-cell, uxui-cell)
|
||||
- Cross-cell channels (dev-all, qa-all, pm-all, doc-all)
|
||||
- Management channels (main-pm-board, board-private)
|
||||
- Special channels (announcements, all-hands)
|
||||
|
||||
Auditor has silent read access to all channels.
|
||||
|
||||
### 4. API Integration
|
||||
|
||||
#### New Dependencies (`src/roboco/api/deps.py`)
|
||||
- `PermissionServiceDep` - Injects permission service
|
||||
- `CurrentAgentContext` - Full agent context from headers
|
||||
- `require_channel_read()` - Dependency factory for channel read checks
|
||||
- `require_channel_write()` - Dependency factory for channel write checks
|
||||
- `require_notification_permission()` - Dependency for notification checks
|
||||
|
||||
#### New Routes (`src/roboco/api/routes/stream.py`)
|
||||
| Endpoint | Method | Description |
|
||||
|----------|--------|-------------|
|
||||
| `/api/v1/stream/chunk` | POST | Process a stream chunk |
|
||||
| `/api/v1/stream/complete` | POST | Mark stream complete, get content |
|
||||
| `/api/v1/stream/extract` | POST | Extract messages from content |
|
||||
| `/api/v1/stream/stats` | GET | Transcription service stats |
|
||||
| `/api/v1/stream/permissions` | GET | Get agent's permission summary |
|
||||
| `/api/v1/stream/permissions/channel/{name}` | GET | Check specific channel access |
|
||||
|
||||
#### App Integration (`src/roboco/api/app.py`)
|
||||
- Services initialized in lifespan context
|
||||
- `app.state.transcription` - Global transcription service
|
||||
- `app.state.extraction` - Global extraction pipeline
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/services/
|
||||
├── __init__.py # Service exports
|
||||
├── transcription.py # StreamBuffer, TranscriptionService
|
||||
├── extraction.py # ExtractionService, ExtractionPipeline
|
||||
└── permissions.py # PermissionService, matrices
|
||||
```
|
||||
|
||||
## Next Steps (Phase 3: Intelligence)
|
||||
Per HOMELAB_TEAM_V0.md section 13.5:
|
||||
- [ ] Setup Qdrant on NAS
|
||||
- [ ] Build embedding pipeline
|
||||
- [ ] Implement Optimal API (RAG queries)
|
||||
- [ ] Implement Journal API
|
||||
- [ ] Index existing repositories
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 2 communication services complete. Transcription buffers LLM streams, extraction classifies message types, and permissions enforce the communication matrix from the blueprint. All services are integrated with the FastAPI application and accessible via `/api/v1/stream/*` endpoints. Ready for Phase 3 which adds RAG/knowledge base capabilities.
|
||||
@@ -0,0 +1,175 @@
|
||||
# TASK-001: Phase 3 - Intelligence Services
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 3 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.5):
|
||||
- RAG system using piragi with PostgreSQL/pgvector
|
||||
- Optimal API for knowledge base queries
|
||||
- Journal API for agent personal logs
|
||||
- Embedding pipeline integration
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] pgvector enabled in PostgreSQL (docker-compose updated)
|
||||
- [x] piragi[postgres] added as dependency
|
||||
- [x] Optimal API service with piragi
|
||||
- [x] Journal API service
|
||||
- [x] API routes for knowledge base operations
|
||||
- [x] API routes for journal operations
|
||||
- [x] Integration with existing extraction pipeline
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Infrastructure Changes
|
||||
|
||||
#### Docker Compose (`docker-compose.yml`)
|
||||
- Changed PostgreSQL image from `postgres:16-alpine` to `pgvector/pgvector:pg16`
|
||||
- Removed Qdrant container (replaced by pgvector)
|
||||
- Removed `qdrant_data` volume
|
||||
|
||||
#### Dependencies (`pyproject.toml`)
|
||||
- Replaced `qdrant-client>=1.7.0` with `piragi[postgres]>=0.1.0`
|
||||
- Updated mypy overrides for piragi
|
||||
|
||||
### 2. Configuration (`src/roboco/config.py`)
|
||||
| Setting | Default | Description |
|
||||
|---------|---------|-------------|
|
||||
| `rag_persist_dir` | `.piragi` | Directory for piragi index data |
|
||||
| `rag_chunk_strategy` | `semantic` | Chunking: fixed, semantic, hierarchical, contextual |
|
||||
| `rag_chunk_size` | 512 | Characters per chunk |
|
||||
| `rag_chunk_overlap` | 50 | Overlap between chunks |
|
||||
| `rag_use_hyde` | True | Hypothetical document embeddings |
|
||||
| `rag_use_hybrid_search` | True | BM25 + vector hybrid search |
|
||||
| `rag_use_cross_encoder` | False | Neural reranking (slower) |
|
||||
| `rag_auto_update_enabled` | True | Background index updates |
|
||||
| `rag_auto_update_interval` | 300 | Seconds between updates |
|
||||
| `rag_store_url` | computed | PostgreSQL connection for piragi |
|
||||
|
||||
### 3. Optimal API Service (`src/roboco/services/optimal.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `IndexType` | Enum: CODE, DOCUMENTATION, CONVERSATIONS, JOURNALS |
|
||||
| `SearchResult` | Single search result with content, source, score |
|
||||
| `RAGResponse` | Answer with citations |
|
||||
| `QueryContext` | Filters: project, task_id, agent_id, index_types |
|
||||
| `OptimalService` | Main service using AsyncRagi |
|
||||
|
||||
Key features:
|
||||
- Multiple indexes for different content types
|
||||
- Async initialization and cleanup
|
||||
- Code indexing (files, directories, globs)
|
||||
- Documentation indexing (markdown, URLs, crawling)
|
||||
- Conversation indexing (from extraction pipeline)
|
||||
- Journal entry indexing (automatic on creation)
|
||||
- Semantic search across all indexes
|
||||
- RAG queries with citations
|
||||
- HyDE and hybrid search enabled by default
|
||||
|
||||
### 4. Journal API Service (`src/roboco/services/journal.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `JournalStats` | Entry counts, timestamps, summary status |
|
||||
| `GrowthMetrics` | Learning frequency, resolution rates, trends |
|
||||
| `JournalService` | Full CRUD for journals and entries |
|
||||
|
||||
Key features:
|
||||
- Get or create journal per agent
|
||||
- Create entries with automatic RAG indexing
|
||||
- Convenience methods for entry types:
|
||||
- Task reflections
|
||||
- Decision logs
|
||||
- Learning entries
|
||||
- Struggle entries
|
||||
- General notes
|
||||
- List entries with filtering (type, task, privacy)
|
||||
- Journal statistics
|
||||
- Growth metrics calculation
|
||||
- Semantic search through entries
|
||||
|
||||
### 5. API Routes
|
||||
|
||||
#### Optimal API (`src/roboco/api/routes/optimal.py`)
|
||||
| Endpoint | Method | Description |
|
||||
|----------|--------|-------------|
|
||||
| `/api/v1/optimal/kb/index/code` | POST | Index code files |
|
||||
| `/api/v1/optimal/kb/index/docs` | POST | Index documentation |
|
||||
| `/api/v1/optimal/kb/search` | POST | Semantic search |
|
||||
| `/api/v1/optimal/kb/similar` | GET | Find similar documents |
|
||||
| `/api/v1/optimal/rag/query` | POST | RAG query with answer |
|
||||
| `/api/v1/optimal/rag/context` | POST | Get context without answer |
|
||||
| `/api/v1/optimal/stats` | GET | Index statistics |
|
||||
| `/api/v1/optimal/kb/{type}` | DELETE | Clear an index |
|
||||
| `/api/v1/optimal/kb/refresh` | POST | Refresh index sources |
|
||||
|
||||
#### Journal API (`src/roboco/api/routes/journals.py`)
|
||||
| Endpoint | Method | Description |
|
||||
|----------|--------|-------------|
|
||||
| `/api/v1/journals/me` | GET | Get my journal |
|
||||
| `/api/v1/journals/{agent_id}` | GET | Get journal by agent |
|
||||
| `/api/v1/journals/me/entries` | GET | List my entries |
|
||||
| `/api/v1/journals/me/entries` | POST | Create entry |
|
||||
| `/api/v1/journals/entries/{id}` | GET | Get entry |
|
||||
| `/api/v1/journals/entries/{id}` | DELETE | Delete entry |
|
||||
| `/api/v1/journals/me/reflections` | POST | Add task reflection |
|
||||
| `/api/v1/journals/me/decisions` | POST | Add decision log |
|
||||
| `/api/v1/journals/me/learnings` | POST | Add learning |
|
||||
| `/api/v1/journals/me/struggles` | POST | Add struggle |
|
||||
| `/api/v1/journals/me/notes` | POST | Add general note |
|
||||
| `/api/v1/journals/me/stats` | GET | Get journal stats |
|
||||
| `/api/v1/journals/me/growth` | GET | Get growth metrics |
|
||||
| `/api/v1/journals/me/search` | POST | Semantic search entries |
|
||||
|
||||
### 6. App Integration (`src/roboco/api/app.py`)
|
||||
- OptimalService initialized in lifespan
|
||||
- Stored in `app.state.optimal`
|
||||
- Proper cleanup on shutdown
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/services/
|
||||
├── __init__.py # Updated with Phase 3 exports
|
||||
├── transcription.py # Phase 2
|
||||
├── extraction.py # Phase 2
|
||||
├── permissions.py # Phase 2
|
||||
├── optimal.py # NEW - RAG/Knowledge Base
|
||||
└── journal.py # NEW - Agent Journals
|
||||
|
||||
src/roboco/api/routes/
|
||||
├── __init__.py # Updated with new routes
|
||||
├── ... (Phase 1-2 routes)
|
||||
├── optimal.py # NEW - Optimal API endpoints
|
||||
└── journals.py # NEW - Journal API endpoints
|
||||
```
|
||||
|
||||
## Technology Choice: piragi
|
||||
|
||||
Selected piragi over Qdrant because:
|
||||
1. **Simpler stack** - Uses existing PostgreSQL with pgvector extension
|
||||
2. **Zero config** - Works with local models out of the box
|
||||
3. **Advanced retrieval** - Built-in HyDE, hybrid search, cross-encoder reranking
|
||||
4. **Async support** - AsyncRagi for FastAPI integration
|
||||
5. **Multiple sources** - Files, directories, URLs, globs, web crawling
|
||||
6. **Auto-updates** - Background refresh without blocking queries
|
||||
|
||||
## Next Steps (Phase 4: Agents)
|
||||
Per HOMELAB_TEAM_V0.md section 13.6:
|
||||
- [ ] Define agent prompts per role
|
||||
- [ ] Implement Dev workflow
|
||||
- [ ] Implement QA workflow
|
||||
- [ ] Implement Documenter workflow
|
||||
- [ ] Implement PM workflows
|
||||
- [ ] Deploy Backend cell
|
||||
- [ ] Deploy Frontend cell
|
||||
- [ ] Deploy UX/UI cell
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 3 intelligence services complete. Using piragi with pgvector for RAG instead of Qdrant - simpler stack, same functionality. Optimal API provides knowledge base indexing and queries. Journal API provides agent personal logs with automatic RAG indexing. All entries are searchable via semantic search. Ready for Phase 4 which implements the actual agent workflows.
|
||||
@@ -0,0 +1,215 @@
|
||||
# TASK-001: Phase 4 - Agents
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 4 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.6):
|
||||
- Define all 17 agent types with role-specific workflows
|
||||
- Implement the task lifecycle for each role
|
||||
- Create cell deployment infrastructure
|
||||
- Enable 3 functioning cells + Board
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Developer workflow implemented (SCAN → CLAIM → UNDERSTAND → PLAN → EXECUTE → VERIFY → NOTES → CLOSE)
|
||||
- [x] QA workflow implemented (MONITOR → RECEIVE → UNDERSTAND → TEST → VERDICT → DOCUMENT → RETURN)
|
||||
- [x] Documenter workflow implemented (MONITOR → RECEIVE → GATHER → SYNTHESIZE → WRITE → REVIEW → PUBLISH)
|
||||
- [x] Cell PM workflow implemented (MONITOR → TRIAGE → ASSIGN → FACILITATE → ESCALATE → TRACK → REPORT)
|
||||
- [x] Main PM workflow implemented (OVERSEE → RECEIVE → PRIORITIZE → COORDINATE → DISTRIBUTE → REPORT UP → FACILITATE)
|
||||
- [x] Board workflows implemented (Product Owner, Head of Marketing, Auditor)
|
||||
- [x] Cell factory and deployment system
|
||||
- [x] Organization factory for complete deployment
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Developer Agent (`src/roboco/agents/developer.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `DevTaskPhase` | Enum: SCAN, CLAIM, UNDERSTAND, PLAN, EXECUTE, VERIFY, NOTES, CLOSE, BLOCKED |
|
||||
| `TaskContext` | Dataclass tracking current task state, subtasks, commits, journal |
|
||||
| `DeveloperAgent` | Full lifecycle implementation with LLM integration |
|
||||
|
||||
Key features:
|
||||
- Phase-based task execution
|
||||
- Subtask breakdown and tracking
|
||||
- Quality checks (ruff, mypy, pytest)
|
||||
- Journal entries at each phase
|
||||
- Handoff creation for documenter
|
||||
- Factory functions for BE/FE/UX developers
|
||||
|
||||
### 2. QA Agent (`src/roboco/agents/qa.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `QATaskPhase` | Enum: MONITOR, RECEIVE, UNDERSTAND, TEST, VERDICT, DOCUMENT, RETURN |
|
||||
| `TestCase` | Dataclass for test execution and results |
|
||||
| `ReviewContext` | Dataclass tracking review state |
|
||||
| `QAAgent` | Full review lifecycle implementation |
|
||||
|
||||
Key features:
|
||||
- Test case generation from requirements
|
||||
- Automated test execution
|
||||
- Clear PASS/FAIL verdicts
|
||||
- Specific feedback for failures
|
||||
- QA report generation
|
||||
|
||||
### 3. Documenter Agent (`src/roboco/agents/documenter.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `DocTaskPhase` | Enum: MONITOR, RECEIVE, GATHER, SYNTHESIZE, WRITE, REVIEW, PUBLISH |
|
||||
| `DocType` | Enum: API, README, ARCHITECTURE, CHANGELOG, etc. |
|
||||
| `DocumentSpec` | Dataclass for document specifications |
|
||||
| `DocumenterAgent` | Full documentation lifecycle |
|
||||
|
||||
Key features:
|
||||
- Material gathering (notes, commits, conversations)
|
||||
- Synthesis of what was built
|
||||
- Automatic document type detection
|
||||
- Self-review before publish
|
||||
- Factory functions for all cells
|
||||
|
||||
### 4. PM Agents (`src/roboco/agents/pm.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `CellPMPhase` | Enum: MONITOR, TRIAGE, ASSIGN, FACILITATE, ESCALATE, TRACK, REPORT |
|
||||
| `MainPMPhase` | Enum: OVERSEE, RECEIVE, PRIORITIZE, COORDINATE, DISTRIBUTE, REPORT_UP, FACILITATE |
|
||||
| `CellPMAgent` | Cell-level management |
|
||||
| `MainPMAgent` | Organization-level coordination |
|
||||
|
||||
Key features:
|
||||
- Continuous duty cycles (never complete)
|
||||
- Task prioritization and assignment
|
||||
- Blocker facilitation
|
||||
- Escalation handling
|
||||
- Status reporting
|
||||
- Cross-cell coordination (Main PM)
|
||||
|
||||
### 5. Board Agents (`src/roboco/agents/board.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `ProductOwnerAgent` | Vision, roadmap, requirements, acceptance |
|
||||
| `HeadMarketingAgent` | Research, strategy, campaigns, analytics |
|
||||
| `AuditorAgent` | Silent observation, analysis, CEO reporting |
|
||||
|
||||
Auditor special powers:
|
||||
- Read ALL channels silently
|
||||
- Query all task history
|
||||
- Access all commits, docs, notes
|
||||
- Direct line to CEO
|
||||
- Can notify anyone (sparingly)
|
||||
|
||||
### 6. Factory and Deployment (`src/roboco/agents/factory.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `Cell` | Complete cell with PM, Devs, QA, Documenter |
|
||||
| `Board` | Product Owner, Head of Marketing, Auditor |
|
||||
| `Organization` | Complete 18-agent organization |
|
||||
|
||||
Factory functions:
|
||||
- `create_backend_cell()` - 5 agents
|
||||
- `create_frontend_cell()` - 5 agents
|
||||
- `create_ux_cell()` - 4 agents
|
||||
- `create_board()` - 3 agents
|
||||
- `create_organization()` - Complete deployment
|
||||
|
||||
Utility functions:
|
||||
- `get_agent_roster()` - List all agents without instantiation
|
||||
- `print_org_chart()` - Text-based org visualization
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/agents/
|
||||
├── __init__.py # Updated with all exports
|
||||
├── base.py # Phase 1 - Base Agent class
|
||||
├── orchestrator.py # Phase 1 - Agent orchestration
|
||||
├── developer.py # NEW - Developer lifecycle
|
||||
├── qa.py # NEW - QA lifecycle
|
||||
├── documenter.py # NEW - Documenter lifecycle
|
||||
├── pm.py # NEW - Cell PM and Main PM
|
||||
├── board.py # NEW - Product Owner, Marketing, Auditor
|
||||
└── factory.py # NEW - Cell and Organization factories
|
||||
```
|
||||
|
||||
## Agent Count
|
||||
|
||||
| Level | Count | Agents |
|
||||
|-------|-------|--------|
|
||||
| Executive | 1 | CEO (Human) |
|
||||
| Board | 3 | Product Owner, Head of Marketing, Auditor |
|
||||
| Management | 1 | Main PM |
|
||||
| Backend Cell | 5 | PM, 2 Devs, QA, Documenter |
|
||||
| Frontend Cell | 5 | PM, 2 Devs, QA, Documenter |
|
||||
| UX/UI Cell | 4 | PM, 1 Dev, QA, Documenter |
|
||||
| **Total** | **19** | 18 AI + 1 Human CEO |
|
||||
|
||||
## Workflow Summary
|
||||
|
||||
### Developer Lifecycle
|
||||
```
|
||||
SCAN → CLAIM → UNDERSTAND → PLAN → EXECUTE → VERIFY → NOTES → CLOSE
|
||||
│ │ │
|
||||
└─────── BLOCKED ───────────┴────────┘
|
||||
```
|
||||
|
||||
### QA Lifecycle
|
||||
```
|
||||
MONITOR → RECEIVE → UNDERSTAND → TEST → VERDICT → DOCUMENT → RETURN
|
||||
│
|
||||
PASS ─┴─ FAIL
|
||||
```
|
||||
|
||||
### Documenter Lifecycle
|
||||
```
|
||||
MONITOR → RECEIVE → GATHER → SYNTHESIZE → WRITE → REVIEW → PUBLISH
|
||||
```
|
||||
|
||||
### Cell PM Lifecycle (Continuous)
|
||||
```
|
||||
MONITOR → TRIAGE → ASSIGN → FACILITATE → ESCALATE → TRACK → REPORT
|
||||
▲ │
|
||||
└──────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Usage Example
|
||||
|
||||
```python
|
||||
from roboco.agents import create_organization
|
||||
|
||||
# Create complete organization
|
||||
org = create_organization()
|
||||
|
||||
# Start all agents
|
||||
await org.start_all()
|
||||
|
||||
# Access specific agents
|
||||
be_dev = org.get_agent_by_slug("be-dev-1")
|
||||
auditor = org.board.auditor
|
||||
|
||||
# Get cell status
|
||||
backend_agents = org.get_agents_by_team(Team.BACKEND)
|
||||
|
||||
# Stop all agents
|
||||
await org.stop_all()
|
||||
```
|
||||
|
||||
## Next Steps (Phase 5: Management)
|
||||
Per HOMELAB_TEAM_V0.md section 13.7:
|
||||
- [ ] Build Kanban interfaces
|
||||
- [ ] Create Auditor dashboard
|
||||
- [ ] Create CEO overview
|
||||
- [ ] Implement metrics collection
|
||||
- [ ] Build reporting system
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 4 agents complete. All 17 agent types implemented with role-specific workflows. Each agent follows its lifecycle from the blueprint (Section 7). Factory functions create complete cells and the full organization. Agents load system prompts from blueprint files in `agents/blueprints/`. Ready for Phase 5 which adds management UIs and dashboards.
|
||||
@@ -0,0 +1,222 @@
|
||||
# TASK-001: Phase 5 - Management
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 5 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.7):
|
||||
- Build Task API for task CRUD and status management
|
||||
- Create Kanban service with role-specific board views
|
||||
- Implement metrics collection and reporting
|
||||
- Build Auditor dashboard API
|
||||
- Build CEO overview API
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Task API with full CRUD operations
|
||||
- [x] Task service with status transitions and lifecycle management
|
||||
- [x] Kanban service with board views for each role
|
||||
- [x] Dev Kanban: Backlog → Assigned → In Progress → QA Review → Documenting → Done
|
||||
- [x] QA Kanban: Awaiting Review → In Review → Passed → Failed
|
||||
- [x] Documenter Kanban: Awaiting Handoff → Gathering → Writing → Published
|
||||
- [x] PM Kanban: Incoming → Triaged → Assigned → In Progress → Blocked → Done
|
||||
- [x] Main PM Kanban: Cross-cell view with Backend/Frontend/UX columns
|
||||
- [x] Board Kanban: Ideas → Roadmap → In Development → Released
|
||||
- [x] Metrics collection (velocity, blockers, completion rate)
|
||||
- [x] Auditor dashboard API (live feeds, flagged items, metrics, reports)
|
||||
- [x] CEO overview API (health status, key metrics, auditor alerts, roadmap progress)
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Task Service (`src/roboco/services/task.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `TaskService` | Full CRUD operations for tasks |
|
||||
| Status transitions | claim, start, block, unblock, pause, resume, verify, submit_for_qa, pass_qa, fail_qa, complete, cancel |
|
||||
| Progress tracking | add_progress, add_checkpoint, add_commit |
|
||||
| Queries | list_all, list_by_team, list_by_assignee, list_by_status, list_pending, list_blocked, list_awaiting_qa, list_awaiting_docs |
|
||||
| Statistics | count_by_status, count_by_team, get_active_count |
|
||||
|
||||
### 2. Task API Routes (`src/roboco/api/routes/tasks.py`)
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `GET/POST /tasks` | List and create tasks |
|
||||
| `GET/PUT/DELETE /tasks/{id}` | Task CRUD |
|
||||
| `GET /tasks/my` | Get agent's tasks |
|
||||
| `GET /tasks/pending, /blocked, /awaiting-qa, /awaiting-docs` | Status-based lists |
|
||||
| `GET /tasks/team/{team}` | Team tasks |
|
||||
| `GET /tasks/stats` | Task statistics |
|
||||
| `POST /tasks/{id}/claim, /start, /block, /unblock, /pause, /resume` | Lifecycle transitions |
|
||||
| `POST /tasks/{id}/verify, /submit-qa, /pass-qa, /fail-qa, /complete, /cancel` | Review transitions |
|
||||
| `POST /tasks/{id}/progress, /checkpoint, /commit` | Progress and artifacts |
|
||||
|
||||
### 3. Kanban Models (`src/roboco/models/kanban.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `KanbanBoardType` | Enum: DEV, QA, DOCUMENTER, PM, MAIN_PM, BOARD |
|
||||
| `KanbanCard` | Card representation with task data |
|
||||
| `KanbanColumn` | Column with cards and WIP limit |
|
||||
| `KanbanSwimlane` | Swimlane for grouping |
|
||||
| `KanbanBoard` | Complete board with columns or swimlanes |
|
||||
| Column configs | DEV_COLUMNS, QA_COLUMNS, DOCUMENTER_COLUMNS, PM_COLUMNS, MAIN_PM_COLUMNS, BOARD_COLUMNS |
|
||||
|
||||
### 4. Kanban Service (`src/roboco/services/kanban.py`)
|
||||
|
||||
| Method | Description |
|
||||
|--------|-------------|
|
||||
| `get_dev_board(team, swimlane_by)` | Dev board with optional swimlanes |
|
||||
| `get_qa_board(team)` | QA review board |
|
||||
| `get_documenter_board(team)` | Documenter board |
|
||||
| `get_pm_board(team)` | Cell PM board |
|
||||
| `get_main_pm_board()` | Cross-cell Main PM board |
|
||||
| `get_main_pm_board_flat()` | Flat team-column view |
|
||||
| `get_board_kanban()` | Board-level roadmap |
|
||||
| `get_board_stats(team)` | Board statistics |
|
||||
|
||||
### 5. Kanban API Routes (`src/roboco/api/routes/kanban.py`)
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `GET /kanban/dev/{team}` | Dev board with swimlane option |
|
||||
| `GET /kanban/qa/{team}` | QA board |
|
||||
| `GET /kanban/documenter/{team}` | Documenter board |
|
||||
| `GET /kanban/pm/{team}` | Cell PM board |
|
||||
| `GET /kanban/main-pm` | Main PM cross-cell board |
|
||||
| `GET /kanban/board` | Board-level roadmap |
|
||||
| `GET /kanban/stats` | Board statistics |
|
||||
|
||||
### 6. Metrics Service (`src/roboco/services/metrics.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `VelocityMetrics` | Tasks completed, created, avg time, completion rate |
|
||||
| `BlockerMetrics` | Active blockers, avg time, longest blocked, by team |
|
||||
| `TeamMetrics` | Active/blocked/completed tasks, avg time, doc coverage |
|
||||
| `AgentMetrics` | Agent performance and activity |
|
||||
| `get_velocity(days, team)` | Velocity metrics |
|
||||
| `get_blocker_metrics()` | Blocker analysis |
|
||||
| `get_team_metrics(team)` | Team performance |
|
||||
| `get_agent_metrics(agent_id)` | Agent performance |
|
||||
| `get_communication_volume(hours)` | Message and notification counts |
|
||||
| `get_health_status(team)` | ok/slow/critical status |
|
||||
|
||||
### 7. Dashboard API Routes (`src/roboco/api/routes/dashboard.py`)
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `GET /dashboard/auditor` | Complete auditor dashboard |
|
||||
| `GET /dashboard/auditor/flags` | Auditor flags with filters |
|
||||
| `POST /dashboard/auditor/flags` | Create flag |
|
||||
| `PUT /dashboard/auditor/flags/{id}/resolve` | Resolve flag |
|
||||
| `GET /dashboard/auditor/reports` | Auditor reports |
|
||||
| `POST /dashboard/auditor/reports` | Create report |
|
||||
| `POST /dashboard/auditor/reports/{id}/send` | Send to CEO |
|
||||
| `GET /dashboard/ceo` | CEO overview |
|
||||
| `GET /dashboard/ceo/teams` | Team details |
|
||||
| `GET /dashboard/ceo/blockers` | Blocker details |
|
||||
| `GET /dashboard/ceo/velocity` | Velocity metrics |
|
||||
| `GET /dashboard/metrics/*` | Various metric endpoints |
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/
|
||||
├── models/
|
||||
│ └── kanban.py # NEW - Kanban board models
|
||||
├── services/
|
||||
│ ├── task.py # NEW - Task CRUD and lifecycle
|
||||
│ ├── kanban.py # NEW - Kanban board generation
|
||||
│ └── metrics.py # NEW - Metrics collection
|
||||
├── api/routes/
|
||||
│ ├── tasks.py # NEW - Task API
|
||||
│ ├── kanban.py # NEW - Kanban API
|
||||
│ └── dashboard.py # NEW - Dashboard API
|
||||
└── api/
|
||||
└── app.py # Updated with new routes
|
||||
```
|
||||
|
||||
## API Summary
|
||||
|
||||
### Task API
|
||||
- Full CRUD for tasks
|
||||
- Complete lifecycle management (claim → start → verify → qa → docs → complete)
|
||||
- Progress tracking and checkpoints
|
||||
- Commit linking
|
||||
|
||||
### Kanban API
|
||||
- 6 board types for different roles
|
||||
- Swimlane support (by priority, assignee)
|
||||
- Cross-cell views for Main PM
|
||||
- Roadmap view for Board
|
||||
|
||||
### Dashboard API
|
||||
- Auditor: Live feeds, flags, metrics, reports
|
||||
- CEO: Health status, metrics, alerts, roadmap
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Create and Track a Task
|
||||
```python
|
||||
# Create task
|
||||
POST /api/v1/tasks
|
||||
{
|
||||
"title": "Implement feature X",
|
||||
"description": "...",
|
||||
"acceptance_criteria": ["..."],
|
||||
"team": "backend",
|
||||
"priority": 1
|
||||
}
|
||||
|
||||
# Claim and start
|
||||
POST /api/v1/tasks/{id}/claim
|
||||
POST /api/v1/tasks/{id}/start
|
||||
|
||||
# Add progress
|
||||
POST /api/v1/tasks/{id}/progress
|
||||
{"message": "Completed first subtask", "percentage": 30}
|
||||
|
||||
# Submit for QA
|
||||
POST /api/v1/tasks/{id}/submit-qa
|
||||
```
|
||||
|
||||
### View Kanban Boards
|
||||
```python
|
||||
# Dev board with priority swimlanes
|
||||
GET /api/v1/kanban/dev/backend?swimlane_by=priority
|
||||
|
||||
# Main PM cross-cell view
|
||||
GET /api/v1/kanban/main-pm?flat=true
|
||||
|
||||
# Board-level roadmap
|
||||
GET /api/v1/kanban/board
|
||||
```
|
||||
|
||||
### CEO Overview
|
||||
```python
|
||||
# Get full overview
|
||||
GET /api/v1/dashboard/ceo
|
||||
|
||||
# Response includes:
|
||||
# - health_status: [{team, status, active_tasks, blocked_tasks, ...}]
|
||||
# - key_metrics: {velocity_weekly, completion_rate, doc_coverage, blockers}
|
||||
# - auditor_alerts: {urgent_count, warning_count, last_report_at}
|
||||
# - roadmap_progress: {current_quarter_progress, priority_totals}
|
||||
```
|
||||
|
||||
## Next Steps (Phase 6: Polish)
|
||||
Per HOMELAB_TEAM_V0.md section 13.8:
|
||||
- [ ] Performance optimization
|
||||
- [ ] Comprehensive documentation
|
||||
- [ ] Test coverage
|
||||
- [ ] Error handling improvements
|
||||
- [ ] Logging and observability
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 5 management complete. Task API provides full CRUD with lifecycle transitions. Kanban service generates role-specific boards with swimlane support. Metrics service tracks velocity, blockers, and agent performance. Auditor dashboard provides live feeds, flags, and reporting. CEO overview aggregates health status, metrics, and roadmap progress. Ready for Phase 6 polish.
|
||||
@@ -0,0 +1,200 @@
|
||||
# TASK-001: Phase 6 - Polish
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 6 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.8):
|
||||
- Error handling improvements with custom exceptions
|
||||
- Structured logging throughout with correlation IDs
|
||||
- Database migrations with Alembic
|
||||
- Middleware for request tracking and error handling
|
||||
- Code quality and consistency
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Comprehensive error handling with custom exceptions
|
||||
- [x] Structured logging with correlation IDs
|
||||
- [x] Alembic migration for all tables
|
||||
- [x] Request/response logging middleware
|
||||
- [x] Error handling middleware with structured responses
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Custom Exceptions (`src/roboco/exceptions.py`)
|
||||
|
||||
| Exception | Description |
|
||||
|-----------|-------------|
|
||||
| `RobocoError` | Base exception with code, message, details |
|
||||
| `NotFoundError` | Resource not found (404) |
|
||||
| `AlreadyExistsError` | Resource already exists (409) |
|
||||
| `ValidationError` | Input validation failed (422) |
|
||||
| `InvalidStateError` | Invalid state transition (409) |
|
||||
| `PermissionDeniedError` | No permission for action (403) |
|
||||
| `AuthenticationError` | Authentication required (401) |
|
||||
| `TaskError` | Base task error |
|
||||
| `TaskLifecycleError` | Invalid task state transition |
|
||||
| `TaskBlockedError` | Task blocked by dependencies |
|
||||
| `TaskClaimError` | Cannot claim task |
|
||||
| `AgentError` | Base agent error |
|
||||
| `AgentNotAvailableError` | Agent offline/unavailable |
|
||||
| `AgentBusyError` | Agent working on another task |
|
||||
| `ChannelError` | Base channel error |
|
||||
| `ChannelAccessDeniedError` | No access to channel |
|
||||
| `SessionClosedError` | Session is closed |
|
||||
| `NotificationError` | Notification failed |
|
||||
| `NotificationPermissionError` | Cannot send notifications |
|
||||
| `ServiceError` | External service error |
|
||||
| `DatabaseError` | Database operation failed |
|
||||
| `LLMError` | LLM service error |
|
||||
| `RAGError` | RAG service error |
|
||||
|
||||
All exceptions include:
|
||||
- `code`: Machine-readable error code
|
||||
- `message`: Human-readable description
|
||||
- `details`: Additional context dict
|
||||
- `to_dict()`: Convert to API response format
|
||||
|
||||
### 2. Middleware (`src/roboco/api/middleware.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `CorrelationIdMiddleware` | Adds X-Correlation-ID to requests/responses |
|
||||
| `RequestLoggingMiddleware` | Logs request/response with timing |
|
||||
| `roboco_exception_handler` | Handles RobocoError exceptions |
|
||||
| `generic_exception_handler` | Handles unexpected exceptions |
|
||||
| `setup_middleware(app)` | Setup function for app |
|
||||
|
||||
Features:
|
||||
- Correlation ID from header or auto-generated
|
||||
- Stored in request.state.correlation_id
|
||||
- Bound to structlog context
|
||||
- Added to all error responses
|
||||
- Request timing in X-Response-Time-Ms header
|
||||
|
||||
### 3. Logging Configuration (`src/roboco/logging.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `setup_logging()` | Configure structlog |
|
||||
| `get_logger(name)` | Get structured logger |
|
||||
| `LogContext` | Context manager for temp log context |
|
||||
| `log_operation()` | Create structured log context |
|
||||
|
||||
Features:
|
||||
- Development: Colored console output
|
||||
- Production: JSON output for log aggregation
|
||||
- Consistent format across all modules
|
||||
- Context variables for correlation
|
||||
- App context (version, environment) in all logs
|
||||
|
||||
### 4. Alembic Migration (`alembic/versions/001_initial_schema.py`)
|
||||
|
||||
Creates all tables:
|
||||
- agents
|
||||
- tasks
|
||||
- channels
|
||||
- groups
|
||||
- sessions
|
||||
- messages
|
||||
- notifications
|
||||
- journals
|
||||
- journal_entries
|
||||
- handoffs
|
||||
|
||||
With:
|
||||
- Proper foreign key relationships
|
||||
- Enum types for status/role fields
|
||||
- ARRAY columns for lists
|
||||
- JSON columns for structured data
|
||||
- Performance indexes for common queries
|
||||
|
||||
### 5. Updated Application (`src/roboco/api/app.py`)
|
||||
|
||||
- Logging setup at import time
|
||||
- Startup/shutdown logging
|
||||
- Middleware integration
|
||||
- Error handler registration
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/
|
||||
├── __init__.py # Updated with core exports
|
||||
├── exceptions.py # NEW - Custom exception hierarchy
|
||||
├── logging.py # NEW - Structured logging config
|
||||
├── api/
|
||||
│ ├── app.py # Updated with middleware
|
||||
│ └── middleware.py # NEW - Request/error middleware
|
||||
└── alembic/versions/
|
||||
└── 001_initial_schema.py # NEW - Initial migration
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Raising Exceptions
|
||||
```python
|
||||
from roboco.exceptions import NotFoundError, TaskLifecycleError
|
||||
|
||||
# Resource not found
|
||||
raise NotFoundError("Task", task_id)
|
||||
|
||||
# Invalid state transition
|
||||
raise TaskLifecycleError(
|
||||
task_id=task.id,
|
||||
current_status=task.status.value,
|
||||
target_status="in_progress",
|
||||
)
|
||||
```
|
||||
|
||||
### Structured Logging
|
||||
```python
|
||||
from roboco.logging import get_logger, LogContext, log_operation
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
# Basic logging
|
||||
logger.info("Task created", task_id=str(task.id), title=task.title)
|
||||
|
||||
# With context
|
||||
with LogContext(task_id=str(task.id), agent_id=str(agent.id)):
|
||||
logger.info("Processing task")
|
||||
# All logs in this block have task_id and agent_id
|
||||
|
||||
# Operation logging
|
||||
logger.info("Task updated", **log_operation("update", "task", str(task.id)))
|
||||
```
|
||||
|
||||
### Running Migrations
|
||||
```bash
|
||||
# Create migration
|
||||
alembic revision --autogenerate -m "description"
|
||||
|
||||
# Run migrations
|
||||
alembic upgrade head
|
||||
|
||||
# Rollback
|
||||
alembic downgrade -1
|
||||
```
|
||||
|
||||
## API Error Response Format
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "NOT_FOUND",
|
||||
"message": "Task not found: 123e4567-e89b-12d3-a456-426614174000",
|
||||
"details": {
|
||||
"resource_type": "Task",
|
||||
"resource_id": "123e4567-e89b-12d3-a456-426614174000",
|
||||
"correlation_id": "abc123..."
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 6 polish complete. Custom exception hierarchy with 20+ exception types for proper error handling. Structured logging with correlation IDs for request tracing. Middleware for request logging and error handling. Alembic migration with all 10 tables, proper relationships and indexes. All phases (1-6) of the RoboCo system are now implemented.
|
||||
@@ -0,0 +1,116 @@
|
||||
# TASK-001: Phase 1 - Core Services
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 1 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint:
|
||||
- Database schema
|
||||
- Messaging API
|
||||
- Agent framework
|
||||
- Infrastructure setup
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Database schema designed and implemented
|
||||
- [x] Messaging API (REST) functional
|
||||
- [x] Agent base class created
|
||||
- [x] Simple orchestrator built
|
||||
- [x] PostgreSQL configured
|
||||
- [x] Redis configured
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Project Configuration
|
||||
- `pyproject.toml` - Dependencies, ruff, mypy, pytest config
|
||||
- `docker-compose.yml` - PostgreSQL, Redis, Qdrant
|
||||
- `.env.example` - Environment template
|
||||
- `alembic/` - Migration setup
|
||||
|
||||
### 2. Data Models (`src/roboco/models/`)
|
||||
| File | Models |
|
||||
|------|--------|
|
||||
| `base.py` | All enums (TaskStatus, AgentRole, Team, etc.) |
|
||||
| `task.py` | Task, TaskPlan, Checkpoint, CommitRef |
|
||||
| `agent.py` | Agent, ModelConfig, AgentPermissions |
|
||||
| `session.py` | Session, SessionConfig |
|
||||
| `message.py` | ExtractedMessage, RawStream |
|
||||
| `group.py` | Group |
|
||||
| `channel.py` | Channel |
|
||||
| `notification.py` | Notification |
|
||||
| `journal.py` | Journal, JournalEntry |
|
||||
| `handoff.py` | DocumenterHandoff |
|
||||
|
||||
### 3. Database Layer (`src/roboco/db/`)
|
||||
- `base.py` - Async SQLAlchemy engine, session factory
|
||||
- `tables.py` - All ORM table definitions (10 tables)
|
||||
|
||||
### 4. Configuration (`src/roboco/config.py`)
|
||||
- Environment-based settings via pydantic-settings
|
||||
- Database, Redis, Qdrant, LLM provider configs
|
||||
|
||||
### 5. Messaging API (`src/roboco/api/`)
|
||||
| Route | Endpoints |
|
||||
|-------|-----------|
|
||||
| `health.py` | `/health`, `/ready` |
|
||||
| `channels.py` | CRUD for channels, member management |
|
||||
| `sessions.py` | Session lifecycle |
|
||||
| `messages.py` | Send, edit, delete messages |
|
||||
| `notifications.py` | Send, list, acknowledge |
|
||||
|
||||
### 6. WebSocket (`src/roboco/api/websocket.py`)
|
||||
- `/ws/channels/{id}` - Channel stream
|
||||
- `/ws/agents/{id}` - Agent output stream
|
||||
- `/ws/sessions/{id}` - Session stream
|
||||
- ConnectionManager for broadcasting
|
||||
|
||||
### 7. Agent Framework (`src/roboco/agents/`)
|
||||
- `base.py` - Agent base class with lifecycle, LLM stubs
|
||||
- `orchestrator.py` - Spawn/stop agents, health monitoring
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/
|
||||
├── __init__.py
|
||||
├── config.py
|
||||
├── models/
|
||||
│ ├── __init__.py
|
||||
│ ├── base.py, task.py, agent.py, session.py
|
||||
│ ├── message.py, group.py, channel.py
|
||||
│ ├── notification.py, journal.py, handoff.py
|
||||
│ └── README.md
|
||||
├── db/
|
||||
│ ├── __init__.py
|
||||
│ ├── base.py
|
||||
│ └── tables.py
|
||||
├── api/
|
||||
│ ├── __init__.py
|
||||
│ ├── app.py
|
||||
│ ├── deps.py
|
||||
│ ├── websocket.py
|
||||
│ └── routes/
|
||||
│ ├── __init__.py
|
||||
│ ├── health.py
|
||||
│ ├── channels.py
|
||||
│ ├── sessions.py
|
||||
│ ├── messages.py
|
||||
│ └── notifications.py
|
||||
└── agents/
|
||||
├── __init__.py
|
||||
├── base.py
|
||||
└── orchestrator.py
|
||||
```
|
||||
|
||||
## Next Steps (Phase 2: Communication)
|
||||
Per HOMELAB_TEAM_V0.md section 13.4:
|
||||
- [ ] Transcription service (extract messages from LLM streams)
|
||||
- [ ] Message extraction pipeline
|
||||
- [ ] Permission system
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 1 core services complete. Database schema, Messaging API, and Agent framework are functional. WebSocket streaming is in place. Ready for Phase 2 which adds transcription/extraction pipelines to process agent LLM output into structured messages.
|
||||
@@ -0,0 +1,119 @@
|
||||
# TASK-002: Phase 2 - Communication Services
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 2 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.4):
|
||||
- Transcription service (process LLM stream output)
|
||||
- Message extraction pipeline (identify message types)
|
||||
- Permission system (communication matrix enforcement)
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Transcription service buffers LLM stream chunks
|
||||
- [x] Extraction pipeline classifies messages (reasoning, dialogue, decision, action, blocker, technical)
|
||||
- [x] Permission service enforces channel read/write access
|
||||
- [x] Permission service enforces notification permissions
|
||||
- [x] Permission service enforces communication matrix
|
||||
- [x] API routes for stream processing
|
||||
- [x] API routes for permission checks
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Transcription Service (`src/roboco/services/transcription.py`)
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `StreamBuffer` | Accumulates chunks from agent, tracks timing, detects readiness |
|
||||
| `TranscriptionConfig` | Configurable thresholds (min chars, max chars, idle timeout) |
|
||||
| `TranscriptionService` | Main service with lifecycle, buffering, periodic flush |
|
||||
|
||||
Key features:
|
||||
- Buffers raw LLM output by agent/session
|
||||
- Detects segment boundaries (sentences, pauses, max length)
|
||||
- Background task for periodic buffer checking
|
||||
- Callback registration for ready segments
|
||||
|
||||
### 2. Extraction Service (`src/roboco/services/extraction.py`)
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| Pattern matchers | Regex patterns for each MessageType |
|
||||
| `ExtractionResult` | Container for extracted messages with metadata |
|
||||
| `ExtractionConfig` | Configurable extraction settings |
|
||||
| `ExtractionService` | Pattern-based message classification |
|
||||
| `ExtractionPipeline` | End-to-end processing with callbacks |
|
||||
|
||||
Message types detected:
|
||||
- **REASONING**: "I'm thinking...", "Let me analyze..."
|
||||
- **DIALOGUE**: Questions, @mentions, conversations
|
||||
- **DECISION**: "I've decided...", "Going with..."
|
||||
- **ACTION**: "Starting...", "Committing...", "Done:"
|
||||
- **BLOCKER**: "Blocked:", "Waiting on...", "Error:"
|
||||
- **TECHNICAL**: Code blocks, API explanations
|
||||
|
||||
### 3. Permission Service (`src/roboco/services/permissions.py`)
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `PermissionLevel` | Hierarchy levels (CEO → Board → Main PM → Cell PM → Member) |
|
||||
| `ChannelPermission` | Defines read/write access per channel |
|
||||
| `COMMUNICATION_MATRIX` | Who can communicate with whom |
|
||||
| `NOTIFICATION_TARGETS` | Who can notify whom |
|
||||
| `TASK_PERMISSIONS` | Task actions by role |
|
||||
| `PermissionService` | Main service for all permission checks |
|
||||
|
||||
Channel permissions implemented:
|
||||
- Cell channels (backend-cell, frontend-cell, uxui-cell)
|
||||
- Cross-cell channels (dev-all, qa-all, pm-all, doc-all)
|
||||
- Management channels (main-pm-board, board-private)
|
||||
- Special channels (announcements, all-hands)
|
||||
|
||||
Auditor has silent read access to all channels.
|
||||
|
||||
### 4. API Integration
|
||||
|
||||
#### New Dependencies (`src/roboco/api/deps.py`)
|
||||
- `PermissionServiceDep` - Injects permission service
|
||||
- `CurrentAgentContext` - Full agent context from headers
|
||||
- `require_channel_read()` - Dependency factory for channel read checks
|
||||
- `require_channel_write()` - Dependency factory for channel write checks
|
||||
- `require_notification_permission()` - Dependency for notification checks
|
||||
|
||||
#### New Routes (`src/roboco/api/routes/stream.py`)
|
||||
| Endpoint | Method | Description |
|
||||
|----------|--------|-------------|
|
||||
| `/api/v1/stream/chunk` | POST | Process a stream chunk |
|
||||
| `/api/v1/stream/complete` | POST | Mark stream complete, get content |
|
||||
| `/api/v1/stream/extract` | POST | Extract messages from content |
|
||||
| `/api/v1/stream/stats` | GET | Transcription service stats |
|
||||
| `/api/v1/stream/permissions` | GET | Get agent's permission summary |
|
||||
| `/api/v1/stream/permissions/channel/{name}` | GET | Check specific channel access |
|
||||
|
||||
#### App Integration (`src/roboco/api/app.py`)
|
||||
- Services initialized in lifespan context
|
||||
- `app.state.transcription` - Global transcription service
|
||||
- `app.state.extraction` - Global extraction pipeline
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/services/
|
||||
├── __init__.py # Service exports
|
||||
├── transcription.py # StreamBuffer, TranscriptionService
|
||||
├── extraction.py # ExtractionService, ExtractionPipeline
|
||||
└── permissions.py # PermissionService, matrices
|
||||
```
|
||||
|
||||
## Next Steps (Phase 3: Intelligence)
|
||||
Per HOMELAB_TEAM_V0.md section 13.5:
|
||||
- [ ] Setup Qdrant on NAS
|
||||
- [ ] Build embedding pipeline
|
||||
- [ ] Implement Optimal API (RAG queries)
|
||||
- [ ] Implement Journal API
|
||||
- [ ] Index existing repositories
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 2 communication services complete. Transcription buffers LLM streams, extraction classifies message types, and permissions enforce the communication matrix from the blueprint. All services are integrated with the FastAPI application and accessible via `/api/v1/stream/*` endpoints. Ready for Phase 3 which adds RAG/knowledge base capabilities.
|
||||
@@ -0,0 +1,175 @@
|
||||
# TASK-003: Phase 3 - Intelligence Services
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 3 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.5):
|
||||
- RAG system using piragi with PostgreSQL/pgvector
|
||||
- Optimal API for knowledge base queries
|
||||
- Journal API for agent personal logs
|
||||
- Embedding pipeline integration
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] pgvector enabled in PostgreSQL (docker-compose updated)
|
||||
- [x] piragi[postgres] added as dependency
|
||||
- [x] Optimal API service with piragi
|
||||
- [x] Journal API service
|
||||
- [x] API routes for knowledge base operations
|
||||
- [x] API routes for journal operations
|
||||
- [x] Integration with existing extraction pipeline
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Infrastructure Changes
|
||||
|
||||
#### Docker Compose (`docker-compose.yml`)
|
||||
- Changed PostgreSQL image from `postgres:16-alpine` to `pgvector/pgvector:pg16`
|
||||
- Removed Qdrant container (replaced by pgvector)
|
||||
- Removed `qdrant_data` volume
|
||||
|
||||
#### Dependencies (`pyproject.toml`)
|
||||
- Replaced `qdrant-client>=1.7.0` with `piragi[postgres]>=0.1.0`
|
||||
- Updated mypy overrides for piragi
|
||||
|
||||
### 2. Configuration (`src/roboco/config.py`)
|
||||
| Setting | Default | Description |
|
||||
|---------|---------|-------------|
|
||||
| `rag_persist_dir` | `.piragi` | Directory for piragi index data |
|
||||
| `rag_chunk_strategy` | `semantic` | Chunking: fixed, semantic, hierarchical, contextual |
|
||||
| `rag_chunk_size` | 512 | Characters per chunk |
|
||||
| `rag_chunk_overlap` | 50 | Overlap between chunks |
|
||||
| `rag_use_hyde` | True | Hypothetical document embeddings |
|
||||
| `rag_use_hybrid_search` | True | BM25 + vector hybrid search |
|
||||
| `rag_use_cross_encoder` | False | Neural reranking (slower) |
|
||||
| `rag_auto_update_enabled` | True | Background index updates |
|
||||
| `rag_auto_update_interval` | 300 | Seconds between updates |
|
||||
| `rag_store_url` | computed | PostgreSQL connection for piragi |
|
||||
|
||||
### 3. Optimal API Service (`src/roboco/services/optimal.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `IndexType` | Enum: CODE, DOCUMENTATION, CONVERSATIONS, JOURNALS |
|
||||
| `SearchResult` | Single search result with content, source, score |
|
||||
| `RAGResponse` | Answer with citations |
|
||||
| `QueryContext` | Filters: project, task_id, agent_id, index_types |
|
||||
| `OptimalService` | Main service using AsyncRagi |
|
||||
|
||||
Key features:
|
||||
- Multiple indexes for different content types
|
||||
- Async initialization and cleanup
|
||||
- Code indexing (files, directories, globs)
|
||||
- Documentation indexing (markdown, URLs, crawling)
|
||||
- Conversation indexing (from extraction pipeline)
|
||||
- Journal entry indexing (automatic on creation)
|
||||
- Semantic search across all indexes
|
||||
- RAG queries with citations
|
||||
- HyDE and hybrid search enabled by default
|
||||
|
||||
### 4. Journal API Service (`src/roboco/services/journal.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `JournalStats` | Entry counts, timestamps, summary status |
|
||||
| `GrowthMetrics` | Learning frequency, resolution rates, trends |
|
||||
| `JournalService` | Full CRUD for journals and entries |
|
||||
|
||||
Key features:
|
||||
- Get or create journal per agent
|
||||
- Create entries with automatic RAG indexing
|
||||
- Convenience methods for entry types:
|
||||
- Task reflections
|
||||
- Decision logs
|
||||
- Learning entries
|
||||
- Struggle entries
|
||||
- General notes
|
||||
- List entries with filtering (type, task, privacy)
|
||||
- Journal statistics
|
||||
- Growth metrics calculation
|
||||
- Semantic search through entries
|
||||
|
||||
### 5. API Routes
|
||||
|
||||
#### Optimal API (`src/roboco/api/routes/optimal.py`)
|
||||
| Endpoint | Method | Description |
|
||||
|----------|--------|-------------|
|
||||
| `/api/v1/optimal/kb/index/code` | POST | Index code files |
|
||||
| `/api/v1/optimal/kb/index/docs` | POST | Index documentation |
|
||||
| `/api/v1/optimal/kb/search` | POST | Semantic search |
|
||||
| `/api/v1/optimal/kb/similar` | GET | Find similar documents |
|
||||
| `/api/v1/optimal/rag/query` | POST | RAG query with answer |
|
||||
| `/api/v1/optimal/rag/context` | POST | Get context without answer |
|
||||
| `/api/v1/optimal/stats` | GET | Index statistics |
|
||||
| `/api/v1/optimal/kb/{type}` | DELETE | Clear an index |
|
||||
| `/api/v1/optimal/kb/refresh` | POST | Refresh index sources |
|
||||
|
||||
#### Journal API (`src/roboco/api/routes/journals.py`)
|
||||
| Endpoint | Method | Description |
|
||||
|----------|--------|-------------|
|
||||
| `/api/v1/journals/me` | GET | Get my journal |
|
||||
| `/api/v1/journals/{agent_id}` | GET | Get journal by agent |
|
||||
| `/api/v1/journals/me/entries` | GET | List my entries |
|
||||
| `/api/v1/journals/me/entries` | POST | Create entry |
|
||||
| `/api/v1/journals/entries/{id}` | GET | Get entry |
|
||||
| `/api/v1/journals/entries/{id}` | DELETE | Delete entry |
|
||||
| `/api/v1/journals/me/reflections` | POST | Add task reflection |
|
||||
| `/api/v1/journals/me/decisions` | POST | Add decision log |
|
||||
| `/api/v1/journals/me/learnings` | POST | Add learning |
|
||||
| `/api/v1/journals/me/struggles` | POST | Add struggle |
|
||||
| `/api/v1/journals/me/notes` | POST | Add general note |
|
||||
| `/api/v1/journals/me/stats` | GET | Get journal stats |
|
||||
| `/api/v1/journals/me/growth` | GET | Get growth metrics |
|
||||
| `/api/v1/journals/me/search` | POST | Semantic search entries |
|
||||
|
||||
### 6. App Integration (`src/roboco/api/app.py`)
|
||||
- OptimalService initialized in lifespan
|
||||
- Stored in `app.state.optimal`
|
||||
- Proper cleanup on shutdown
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/services/
|
||||
├── __init__.py # Updated with Phase 3 exports
|
||||
├── transcription.py # Phase 2
|
||||
├── extraction.py # Phase 2
|
||||
├── permissions.py # Phase 2
|
||||
├── optimal.py # NEW - RAG/Knowledge Base
|
||||
└── journal.py # NEW - Agent Journals
|
||||
|
||||
src/roboco/api/routes/
|
||||
├── __init__.py # Updated with new routes
|
||||
├── ... (Phase 1-2 routes)
|
||||
├── optimal.py # NEW - Optimal API endpoints
|
||||
└── journals.py # NEW - Journal API endpoints
|
||||
```
|
||||
|
||||
## Technology Choice: piragi
|
||||
|
||||
Selected piragi over Qdrant because:
|
||||
1. **Simpler stack** - Uses existing PostgreSQL with pgvector extension
|
||||
2. **Zero config** - Works with local models out of the box
|
||||
3. **Advanced retrieval** - Built-in HyDE, hybrid search, cross-encoder reranking
|
||||
4. **Async support** - AsyncRagi for FastAPI integration
|
||||
5. **Multiple sources** - Files, directories, URLs, globs, web crawling
|
||||
6. **Auto-updates** - Background refresh without blocking queries
|
||||
|
||||
## Next Steps (Phase 4: Agents)
|
||||
Per HOMELAB_TEAM_V0.md section 13.6:
|
||||
- [ ] Define agent prompts per role
|
||||
- [ ] Implement Dev workflow
|
||||
- [ ] Implement QA workflow
|
||||
- [ ] Implement Documenter workflow
|
||||
- [ ] Implement PM workflows
|
||||
- [ ] Deploy Backend cell
|
||||
- [ ] Deploy Frontend cell
|
||||
- [ ] Deploy UX/UI cell
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 3 intelligence services complete. Using piragi with pgvector for RAG instead of Qdrant - simpler stack, same functionality. Optimal API provides knowledge base indexing and queries. Journal API provides agent personal logs with automatic RAG indexing. All entries are searchable via semantic search. Ready for Phase 4 which implements the actual agent workflows.
|
||||
@@ -0,0 +1,215 @@
|
||||
# TASK-004: Phase 4 - Agents
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 4 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.6):
|
||||
- Define all 17 agent types with role-specific workflows
|
||||
- Implement the task lifecycle for each role
|
||||
- Create cell deployment infrastructure
|
||||
- Enable 3 functioning cells + Board
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Developer workflow implemented (SCAN → CLAIM → UNDERSTAND → PLAN → EXECUTE → VERIFY → NOTES → CLOSE)
|
||||
- [x] QA workflow implemented (MONITOR → RECEIVE → UNDERSTAND → TEST → VERDICT → DOCUMENT → RETURN)
|
||||
- [x] Documenter workflow implemented (MONITOR → RECEIVE → GATHER → SYNTHESIZE → WRITE → REVIEW → PUBLISH)
|
||||
- [x] Cell PM workflow implemented (MONITOR → TRIAGE → ASSIGN → FACILITATE → ESCALATE → TRACK → REPORT)
|
||||
- [x] Main PM workflow implemented (OVERSEE → RECEIVE → PRIORITIZE → COORDINATE → DISTRIBUTE → REPORT UP → FACILITATE)
|
||||
- [x] Board workflows implemented (Product Owner, Head of Marketing, Auditor)
|
||||
- [x] Cell factory and deployment system
|
||||
- [x] Organization factory for complete deployment
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Developer Agent (`src/roboco/agents/developer.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `DevTaskPhase` | Enum: SCAN, CLAIM, UNDERSTAND, PLAN, EXECUTE, VERIFY, NOTES, CLOSE, BLOCKED |
|
||||
| `TaskContext` | Dataclass tracking current task state, subtasks, commits, journal |
|
||||
| `DeveloperAgent` | Full lifecycle implementation with LLM integration |
|
||||
|
||||
Key features:
|
||||
- Phase-based task execution
|
||||
- Subtask breakdown and tracking
|
||||
- Quality checks (ruff, mypy, pytest)
|
||||
- Journal entries at each phase
|
||||
- Handoff creation for documenter
|
||||
- Factory functions for BE/FE/UX developers
|
||||
|
||||
### 2. QA Agent (`src/roboco/agents/qa.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `QATaskPhase` | Enum: MONITOR, RECEIVE, UNDERSTAND, TEST, VERDICT, DOCUMENT, RETURN |
|
||||
| `TestCase` | Dataclass for test execution and results |
|
||||
| `ReviewContext` | Dataclass tracking review state |
|
||||
| `QAAgent` | Full review lifecycle implementation |
|
||||
|
||||
Key features:
|
||||
- Test case generation from requirements
|
||||
- Automated test execution
|
||||
- Clear PASS/FAIL verdicts
|
||||
- Specific feedback for failures
|
||||
- QA report generation
|
||||
|
||||
### 3. Documenter Agent (`src/roboco/agents/documenter.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `DocTaskPhase` | Enum: MONITOR, RECEIVE, GATHER, SYNTHESIZE, WRITE, REVIEW, PUBLISH |
|
||||
| `DocType` | Enum: API, README, ARCHITECTURE, CHANGELOG, etc. |
|
||||
| `DocumentSpec` | Dataclass for document specifications |
|
||||
| `DocumenterAgent` | Full documentation lifecycle |
|
||||
|
||||
Key features:
|
||||
- Material gathering (notes, commits, conversations)
|
||||
- Synthesis of what was built
|
||||
- Automatic document type detection
|
||||
- Self-review before publish
|
||||
- Factory functions for all cells
|
||||
|
||||
### 4. PM Agents (`src/roboco/agents/pm.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `CellPMPhase` | Enum: MONITOR, TRIAGE, ASSIGN, FACILITATE, ESCALATE, TRACK, REPORT |
|
||||
| `MainPMPhase` | Enum: OVERSEE, RECEIVE, PRIORITIZE, COORDINATE, DISTRIBUTE, REPORT_UP, FACILITATE |
|
||||
| `CellPMAgent` | Cell-level management |
|
||||
| `MainPMAgent` | Organization-level coordination |
|
||||
|
||||
Key features:
|
||||
- Continuous duty cycles (never complete)
|
||||
- Task prioritization and assignment
|
||||
- Blocker facilitation
|
||||
- Escalation handling
|
||||
- Status reporting
|
||||
- Cross-cell coordination (Main PM)
|
||||
|
||||
### 5. Board Agents (`src/roboco/agents/board.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `ProductOwnerAgent` | Vision, roadmap, requirements, acceptance |
|
||||
| `HeadMarketingAgent` | Research, strategy, campaigns, analytics |
|
||||
| `AuditorAgent` | Silent observation, analysis, CEO reporting |
|
||||
|
||||
Auditor special powers:
|
||||
- Read ALL channels silently
|
||||
- Query all task history
|
||||
- Access all commits, docs, notes
|
||||
- Direct line to CEO
|
||||
- Can notify anyone (sparingly)
|
||||
|
||||
### 6. Factory and Deployment (`src/roboco/agents/factory.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `Cell` | Complete cell with PM, Devs, QA, Documenter |
|
||||
| `Board` | Product Owner, Head of Marketing, Auditor |
|
||||
| `Organization` | Complete 18-agent organization |
|
||||
|
||||
Factory functions:
|
||||
- `create_backend_cell()` - 5 agents
|
||||
- `create_frontend_cell()` - 5 agents
|
||||
- `create_ux_cell()` - 4 agents
|
||||
- `create_board()` - 3 agents
|
||||
- `create_organization()` - Complete deployment
|
||||
|
||||
Utility functions:
|
||||
- `get_agent_roster()` - List all agents without instantiation
|
||||
- `print_org_chart()` - Text-based org visualization
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/agents/
|
||||
├── __init__.py # Updated with all exports
|
||||
├── base.py # Phase 1 - Base Agent class
|
||||
├── orchestrator.py # Phase 1 - Agent orchestration
|
||||
├── developer.py # NEW - Developer lifecycle
|
||||
├── qa.py # NEW - QA lifecycle
|
||||
├── documenter.py # NEW - Documenter lifecycle
|
||||
├── pm.py # NEW - Cell PM and Main PM
|
||||
├── board.py # NEW - Product Owner, Marketing, Auditor
|
||||
└── factory.py # NEW - Cell and Organization factories
|
||||
```
|
||||
|
||||
## Agent Count
|
||||
|
||||
| Level | Count | Agents |
|
||||
|-------|-------|--------|
|
||||
| Executive | 1 | CEO (Human) |
|
||||
| Board | 3 | Product Owner, Head of Marketing, Auditor |
|
||||
| Management | 1 | Main PM |
|
||||
| Backend Cell | 5 | PM, 2 Devs, QA, Documenter |
|
||||
| Frontend Cell | 5 | PM, 2 Devs, QA, Documenter |
|
||||
| UX/UI Cell | 4 | PM, 1 Dev, QA, Documenter |
|
||||
| **Total** | **19** | 18 AI + 1 Human CEO |
|
||||
|
||||
## Workflow Summary
|
||||
|
||||
### Developer Lifecycle
|
||||
```
|
||||
SCAN → CLAIM → UNDERSTAND → PLAN → EXECUTE → VERIFY → NOTES → CLOSE
|
||||
│ │ │
|
||||
└─────── BLOCKED ───────────┴────────┘
|
||||
```
|
||||
|
||||
### QA Lifecycle
|
||||
```
|
||||
MONITOR → RECEIVE → UNDERSTAND → TEST → VERDICT → DOCUMENT → RETURN
|
||||
│
|
||||
PASS ─┴─ FAIL
|
||||
```
|
||||
|
||||
### Documenter Lifecycle
|
||||
```
|
||||
MONITOR → RECEIVE → GATHER → SYNTHESIZE → WRITE → REVIEW → PUBLISH
|
||||
```
|
||||
|
||||
### Cell PM Lifecycle (Continuous)
|
||||
```
|
||||
MONITOR → TRIAGE → ASSIGN → FACILITATE → ESCALATE → TRACK → REPORT
|
||||
▲ │
|
||||
└──────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Usage Example
|
||||
|
||||
```python
|
||||
from roboco.agents import create_organization
|
||||
|
||||
# Create complete organization
|
||||
org = create_organization()
|
||||
|
||||
# Start all agents
|
||||
await org.start_all()
|
||||
|
||||
# Access specific agents
|
||||
be_dev = org.get_agent_by_slug("be-dev-1")
|
||||
auditor = org.board.auditor
|
||||
|
||||
# Get cell status
|
||||
backend_agents = org.get_agents_by_team(Team.BACKEND)
|
||||
|
||||
# Stop all agents
|
||||
await org.stop_all()
|
||||
```
|
||||
|
||||
## Next Steps (Phase 5: Management)
|
||||
Per HOMELAB_TEAM_V0.md section 13.7:
|
||||
- [ ] Build Kanban interfaces
|
||||
- [ ] Create Auditor dashboard
|
||||
- [ ] Create CEO overview
|
||||
- [ ] Implement metrics collection
|
||||
- [ ] Build reporting system
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 4 agents complete. All 17 agent types implemented with role-specific workflows. Each agent follows its lifecycle from the blueprint (Section 7). Factory functions create complete cells and the full organization. Agents load system prompts from blueprint files in `agents/blueprints/`. Ready for Phase 5 which adds management UIs and dashboards.
|
||||
@@ -0,0 +1,222 @@
|
||||
# TASK-005: Phase 5 - Management
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 5 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.7):
|
||||
- Build Task API for task CRUD and status management
|
||||
- Create Kanban service with role-specific board views
|
||||
- Implement metrics collection and reporting
|
||||
- Build Auditor dashboard API
|
||||
- Build CEO overview API
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Task API with full CRUD operations
|
||||
- [x] Task service with status transitions and lifecycle management
|
||||
- [x] Kanban service with board views for each role
|
||||
- [x] Dev Kanban: Backlog → Assigned → In Progress → QA Review → Documenting → Done
|
||||
- [x] QA Kanban: Awaiting Review → In Review → Passed → Failed
|
||||
- [x] Documenter Kanban: Awaiting Handoff → Gathering → Writing → Published
|
||||
- [x] PM Kanban: Incoming → Triaged → Assigned → In Progress → Blocked → Done
|
||||
- [x] Main PM Kanban: Cross-cell view with Backend/Frontend/UX columns
|
||||
- [x] Board Kanban: Ideas → Roadmap → In Development → Released
|
||||
- [x] Metrics collection (velocity, blockers, completion rate)
|
||||
- [x] Auditor dashboard API (live feeds, flagged items, metrics, reports)
|
||||
- [x] CEO overview API (health status, key metrics, auditor alerts, roadmap progress)
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Task Service (`src/roboco/services/task.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `TaskService` | Full CRUD operations for tasks |
|
||||
| Status transitions | claim, start, block, unblock, pause, resume, verify, submit_for_qa, pass_qa, fail_qa, complete, cancel |
|
||||
| Progress tracking | add_progress, add_checkpoint, add_commit |
|
||||
| Queries | list_all, list_by_team, list_by_assignee, list_by_status, list_pending, list_blocked, list_awaiting_qa, list_awaiting_docs |
|
||||
| Statistics | count_by_status, count_by_team, get_active_count |
|
||||
|
||||
### 2. Task API Routes (`src/roboco/api/routes/tasks.py`)
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `GET/POST /tasks` | List and create tasks |
|
||||
| `GET/PUT/DELETE /tasks/{id}` | Task CRUD |
|
||||
| `GET /tasks/my` | Get agent's tasks |
|
||||
| `GET /tasks/pending, /blocked, /awaiting-qa, /awaiting-docs` | Status-based lists |
|
||||
| `GET /tasks/team/{team}` | Team tasks |
|
||||
| `GET /tasks/stats` | Task statistics |
|
||||
| `POST /tasks/{id}/claim, /start, /block, /unblock, /pause, /resume` | Lifecycle transitions |
|
||||
| `POST /tasks/{id}/verify, /submit-qa, /pass-qa, /fail-qa, /complete, /cancel` | Review transitions |
|
||||
| `POST /tasks/{id}/progress, /checkpoint, /commit` | Progress and artifacts |
|
||||
|
||||
### 3. Kanban Models (`src/roboco/models/kanban.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `KanbanBoardType` | Enum: DEV, QA, DOCUMENTER, PM, MAIN_PM, BOARD |
|
||||
| `KanbanCard` | Card representation with task data |
|
||||
| `KanbanColumn` | Column with cards and WIP limit |
|
||||
| `KanbanSwimlane` | Swimlane for grouping |
|
||||
| `KanbanBoard` | Complete board with columns or swimlanes |
|
||||
| Column configs | DEV_COLUMNS, QA_COLUMNS, DOCUMENTER_COLUMNS, PM_COLUMNS, MAIN_PM_COLUMNS, BOARD_COLUMNS |
|
||||
|
||||
### 4. Kanban Service (`src/roboco/services/kanban.py`)
|
||||
|
||||
| Method | Description |
|
||||
|--------|-------------|
|
||||
| `get_dev_board(team, swimlane_by)` | Dev board with optional swimlanes |
|
||||
| `get_qa_board(team)` | QA review board |
|
||||
| `get_documenter_board(team)` | Documenter board |
|
||||
| `get_pm_board(team)` | Cell PM board |
|
||||
| `get_main_pm_board()` | Cross-cell Main PM board |
|
||||
| `get_main_pm_board_flat()` | Flat team-column view |
|
||||
| `get_board_kanban()` | Board-level roadmap |
|
||||
| `get_board_stats(team)` | Board statistics |
|
||||
|
||||
### 5. Kanban API Routes (`src/roboco/api/routes/kanban.py`)
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `GET /kanban/dev/{team}` | Dev board with swimlane option |
|
||||
| `GET /kanban/qa/{team}` | QA board |
|
||||
| `GET /kanban/documenter/{team}` | Documenter board |
|
||||
| `GET /kanban/pm/{team}` | Cell PM board |
|
||||
| `GET /kanban/main-pm` | Main PM cross-cell board |
|
||||
| `GET /kanban/board` | Board-level roadmap |
|
||||
| `GET /kanban/stats` | Board statistics |
|
||||
|
||||
### 6. Metrics Service (`src/roboco/services/metrics.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `VelocityMetrics` | Tasks completed, created, avg time, completion rate |
|
||||
| `BlockerMetrics` | Active blockers, avg time, longest blocked, by team |
|
||||
| `TeamMetrics` | Active/blocked/completed tasks, avg time, doc coverage |
|
||||
| `AgentMetrics` | Agent performance and activity |
|
||||
| `get_velocity(days, team)` | Velocity metrics |
|
||||
| `get_blocker_metrics()` | Blocker analysis |
|
||||
| `get_team_metrics(team)` | Team performance |
|
||||
| `get_agent_metrics(agent_id)` | Agent performance |
|
||||
| `get_communication_volume(hours)` | Message and notification counts |
|
||||
| `get_health_status(team)` | ok/slow/critical status |
|
||||
|
||||
### 7. Dashboard API Routes (`src/roboco/api/routes/dashboard.py`)
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `GET /dashboard/auditor` | Complete auditor dashboard |
|
||||
| `GET /dashboard/auditor/flags` | Auditor flags with filters |
|
||||
| `POST /dashboard/auditor/flags` | Create flag |
|
||||
| `PUT /dashboard/auditor/flags/{id}/resolve` | Resolve flag |
|
||||
| `GET /dashboard/auditor/reports` | Auditor reports |
|
||||
| `POST /dashboard/auditor/reports` | Create report |
|
||||
| `POST /dashboard/auditor/reports/{id}/send` | Send to CEO |
|
||||
| `GET /dashboard/ceo` | CEO overview |
|
||||
| `GET /dashboard/ceo/teams` | Team details |
|
||||
| `GET /dashboard/ceo/blockers` | Blocker details |
|
||||
| `GET /dashboard/ceo/velocity` | Velocity metrics |
|
||||
| `GET /dashboard/metrics/*` | Various metric endpoints |
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/
|
||||
├── models/
|
||||
│ └── kanban.py # NEW - Kanban board models
|
||||
├── services/
|
||||
│ ├── task.py # NEW - Task CRUD and lifecycle
|
||||
│ ├── kanban.py # NEW - Kanban board generation
|
||||
│ └── metrics.py # NEW - Metrics collection
|
||||
├── api/routes/
|
||||
│ ├── tasks.py # NEW - Task API
|
||||
│ ├── kanban.py # NEW - Kanban API
|
||||
│ └── dashboard.py # NEW - Dashboard API
|
||||
└── api/
|
||||
└── app.py # Updated with new routes
|
||||
```
|
||||
|
||||
## API Summary
|
||||
|
||||
### Task API
|
||||
- Full CRUD for tasks
|
||||
- Complete lifecycle management (claim → start → verify → qa → docs → complete)
|
||||
- Progress tracking and checkpoints
|
||||
- Commit linking
|
||||
|
||||
### Kanban API
|
||||
- 6 board types for different roles
|
||||
- Swimlane support (by priority, assignee)
|
||||
- Cross-cell views for Main PM
|
||||
- Roadmap view for Board
|
||||
|
||||
### Dashboard API
|
||||
- Auditor: Live feeds, flags, metrics, reports
|
||||
- CEO: Health status, metrics, alerts, roadmap
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Create and Track a Task
|
||||
```python
|
||||
# Create task
|
||||
POST /api/v1/tasks
|
||||
{
|
||||
"title": "Implement feature X",
|
||||
"description": "...",
|
||||
"acceptance_criteria": ["..."],
|
||||
"team": "backend",
|
||||
"priority": 1
|
||||
}
|
||||
|
||||
# Claim and start
|
||||
POST /api/v1/tasks/{id}/claim
|
||||
POST /api/v1/tasks/{id}/start
|
||||
|
||||
# Add progress
|
||||
POST /api/v1/tasks/{id}/progress
|
||||
{"message": "Completed first subtask", "percentage": 30}
|
||||
|
||||
# Submit for QA
|
||||
POST /api/v1/tasks/{id}/submit-qa
|
||||
```
|
||||
|
||||
### View Kanban Boards
|
||||
```python
|
||||
# Dev board with priority swimlanes
|
||||
GET /api/v1/kanban/dev/backend?swimlane_by=priority
|
||||
|
||||
# Main PM cross-cell view
|
||||
GET /api/v1/kanban/main-pm?flat=true
|
||||
|
||||
# Board-level roadmap
|
||||
GET /api/v1/kanban/board
|
||||
```
|
||||
|
||||
### CEO Overview
|
||||
```python
|
||||
# Get full overview
|
||||
GET /api/v1/dashboard/ceo
|
||||
|
||||
# Response includes:
|
||||
# - health_status: [{team, status, active_tasks, blocked_tasks, ...}]
|
||||
# - key_metrics: {velocity_weekly, completion_rate, doc_coverage, blockers}
|
||||
# - auditor_alerts: {urgent_count, warning_count, last_report_at}
|
||||
# - roadmap_progress: {current_quarter_progress, priority_totals}
|
||||
```
|
||||
|
||||
## Next Steps (Phase 6: Polish)
|
||||
Per HOMELAB_TEAM_V0.md section 13.8:
|
||||
- [ ] Performance optimization
|
||||
- [ ] Comprehensive documentation
|
||||
- [ ] Test coverage
|
||||
- [ ] Error handling improvements
|
||||
- [ ] Logging and observability
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 5 management complete. Task API provides full CRUD with lifecycle transitions. Kanban service generates role-specific boards with swimlane support. Metrics service tracks velocity, blockers, and agent performance. Auditor dashboard provides live feeds, flags, and reporting. CEO overview aggregates health status, metrics, and roadmap progress. Ready for Phase 6 polish.
|
||||
@@ -0,0 +1,200 @@
|
||||
# TASK-006: Phase 6 - Polish
|
||||
|
||||
## Status
|
||||
- **State**: completed
|
||||
- **Priority**: P0
|
||||
- **Cell**: board
|
||||
|
||||
## Dates
|
||||
- **Created**: 2025-12-09
|
||||
- **Completed**: 2025-12-09
|
||||
|
||||
## Overview
|
||||
Implement Phase 6 of the RoboCo system per HOMELAB_TEAM_V0.md blueprint (Section 13.8):
|
||||
- Error handling improvements with custom exceptions
|
||||
- Structured logging throughout with correlation IDs
|
||||
- Database migrations with Alembic
|
||||
- Middleware for request tracking and error handling
|
||||
- Code quality and consistency
|
||||
|
||||
## Acceptance Criteria
|
||||
- [x] Comprehensive error handling with custom exceptions
|
||||
- [x] Structured logging with correlation IDs
|
||||
- [x] Alembic migration for all tables
|
||||
- [x] Request/response logging middleware
|
||||
- [x] Error handling middleware with structured responses
|
||||
|
||||
## What Was Built
|
||||
|
||||
### 1. Custom Exceptions (`src/roboco/exceptions.py`)
|
||||
|
||||
| Exception | Description |
|
||||
|-----------|-------------|
|
||||
| `RobocoError` | Base exception with code, message, details |
|
||||
| `NotFoundError` | Resource not found (404) |
|
||||
| `AlreadyExistsError` | Resource already exists (409) |
|
||||
| `ValidationError` | Input validation failed (422) |
|
||||
| `InvalidStateError` | Invalid state transition (409) |
|
||||
| `PermissionDeniedError` | No permission for action (403) |
|
||||
| `AuthenticationError` | Authentication required (401) |
|
||||
| `TaskError` | Base task error |
|
||||
| `TaskLifecycleError` | Invalid task state transition |
|
||||
| `TaskBlockedError` | Task blocked by dependencies |
|
||||
| `TaskClaimError` | Cannot claim task |
|
||||
| `AgentError` | Base agent error |
|
||||
| `AgentNotAvailableError` | Agent offline/unavailable |
|
||||
| `AgentBusyError` | Agent working on another task |
|
||||
| `ChannelError` | Base channel error |
|
||||
| `ChannelAccessDeniedError` | No access to channel |
|
||||
| `SessionClosedError` | Session is closed |
|
||||
| `NotificationError` | Notification failed |
|
||||
| `NotificationPermissionError` | Cannot send notifications |
|
||||
| `ServiceError` | External service error |
|
||||
| `DatabaseError` | Database operation failed |
|
||||
| `LLMError` | LLM service error |
|
||||
| `RAGError` | RAG service error |
|
||||
|
||||
All exceptions include:
|
||||
- `code`: Machine-readable error code
|
||||
- `message`: Human-readable description
|
||||
- `details`: Additional context dict
|
||||
- `to_dict()`: Convert to API response format
|
||||
|
||||
### 2. Middleware (`src/roboco/api/middleware.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `CorrelationIdMiddleware` | Adds X-Correlation-ID to requests/responses |
|
||||
| `RequestLoggingMiddleware` | Logs request/response with timing |
|
||||
| `roboco_exception_handler` | Handles RobocoError exceptions |
|
||||
| `generic_exception_handler` | Handles unexpected exceptions |
|
||||
| `setup_middleware(app)` | Setup function for app |
|
||||
|
||||
Features:
|
||||
- Correlation ID from header or auto-generated
|
||||
- Stored in request.state.correlation_id
|
||||
- Bound to structlog context
|
||||
- Added to all error responses
|
||||
- Request timing in X-Response-Time-Ms header
|
||||
|
||||
### 3. Logging Configuration (`src/roboco/logging.py`)
|
||||
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `setup_logging()` | Configure structlog |
|
||||
| `get_logger(name)` | Get structured logger |
|
||||
| `LogContext` | Context manager for temp log context |
|
||||
| `log_operation()` | Create structured log context |
|
||||
|
||||
Features:
|
||||
- Development: Colored console output
|
||||
- Production: JSON output for log aggregation
|
||||
- Consistent format across all modules
|
||||
- Context variables for correlation
|
||||
- App context (version, environment) in all logs
|
||||
|
||||
### 4. Alembic Migration (`alembic/versions/001_initial_schema.py`)
|
||||
|
||||
Creates all tables:
|
||||
- agents
|
||||
- tasks
|
||||
- channels
|
||||
- groups
|
||||
- sessions
|
||||
- messages
|
||||
- notifications
|
||||
- journals
|
||||
- journal_entries
|
||||
- handoffs
|
||||
|
||||
With:
|
||||
- Proper foreign key relationships
|
||||
- Enum types for status/role fields
|
||||
- ARRAY columns for lists
|
||||
- JSON columns for structured data
|
||||
- Performance indexes for common queries
|
||||
|
||||
### 5. Updated Application (`src/roboco/api/app.py`)
|
||||
|
||||
- Logging setup at import time
|
||||
- Startup/shutdown logging
|
||||
- Middleware integration
|
||||
- Error handler registration
|
||||
|
||||
## File Structure
|
||||
```
|
||||
src/roboco/
|
||||
├── __init__.py # Updated with core exports
|
||||
├── exceptions.py # NEW - Custom exception hierarchy
|
||||
├── logging.py # NEW - Structured logging config
|
||||
├── api/
|
||||
│ ├── app.py # Updated with middleware
|
||||
│ └── middleware.py # NEW - Request/error middleware
|
||||
└── alembic/versions/
|
||||
└── 001_initial_schema.py # NEW - Initial migration
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Raising Exceptions
|
||||
```python
|
||||
from roboco.exceptions import NotFoundError, TaskLifecycleError
|
||||
|
||||
# Resource not found
|
||||
raise NotFoundError("Task", task_id)
|
||||
|
||||
# Invalid state transition
|
||||
raise TaskLifecycleError(
|
||||
task_id=task.id,
|
||||
current_status=task.status.value,
|
||||
target_status="in_progress",
|
||||
)
|
||||
```
|
||||
|
||||
### Structured Logging
|
||||
```python
|
||||
from roboco.logging import get_logger, LogContext, log_operation
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
# Basic logging
|
||||
logger.info("Task created", task_id=str(task.id), title=task.title)
|
||||
|
||||
# With context
|
||||
with LogContext(task_id=str(task.id), agent_id=str(agent.id)):
|
||||
logger.info("Processing task")
|
||||
# All logs in this block have task_id and agent_id
|
||||
|
||||
# Operation logging
|
||||
logger.info("Task updated", **log_operation("update", "task", str(task.id)))
|
||||
```
|
||||
|
||||
### Running Migrations
|
||||
```bash
|
||||
# Create migration
|
||||
alembic revision --autogenerate -m "description"
|
||||
|
||||
# Run migrations
|
||||
alembic upgrade head
|
||||
|
||||
# Rollback
|
||||
alembic downgrade -1
|
||||
```
|
||||
|
||||
## API Error Response Format
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "NOT_FOUND",
|
||||
"message": "Task not found: 123e4567-e89b-12d3-a456-426614174000",
|
||||
"details": {
|
||||
"resource_type": "Task",
|
||||
"resource_id": "123e4567-e89b-12d3-a456-426614174000",
|
||||
"correlation_id": "abc123..."
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Quick Context Restore
|
||||
Phase 6 polish complete. Custom exception hierarchy with 20+ exception types for proper error handling. Structured logging with correlation IDs for request tracing. Middleware for request logging and error handling. Alembic migration with all 10 tables, proper relationships and indexes. All phases (1-6) of the RoboCo system are now implemented.
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user