Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 61 additions & 15 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ This document defines code style guidelines, review criteria, project-specific r

VoidRunner is a distributed task execution platform designed for secure, scalable code execution. The project follows an incremental development approach through well-defined Epic milestones.

### Current Implementation Status (Epic 1 ✅ Complete)
### Current Implementation Status (Epic 1-2 ✅ Complete)
- **Backend**: Go + Gin framework + PostgreSQL (pgx driver)
- **API**: RESTful API with JWT authentication and comprehensive task management
- **Database**: PostgreSQL with optimized schema and cursor pagination
- **Container Execution**: Docker executor with comprehensive security controls
- **Queue System**: Redis-based task queuing with retry logic and dead letter handling
- **Worker Management**: Embedded worker pool with concurrency controls and health monitoring
- **Testing**: 80%+ code coverage with unit and integration tests
- **Documentation**: OpenAPI/Swagger specs with comprehensive examples

### Planned Architecture (Epic 2-4 📋 Roadmap)
- **Container Execution**: Docker + gVisor security for safe code execution
### Planned Architecture (Epic 3-4 📋 Roadmap)
- **Distributed Services**: Separate API and worker services for horizontal scaling
- **Frontend**: Svelte + SvelteKit + TypeScript web interface
- **Infrastructure**: Kubernetes (GKE) deployment with microservices
- **Queue System**: Redis for task scheduling and real-time updates
- **Log Streaming**: Real-time log collection and streaming
- **Monitoring**: Real-time metrics, logging, and alerting systems

## Go Code Standards
Expand All @@ -29,22 +32,21 @@ voidrunner/
├── cmd/ # Application entrypoints
│ ├── api/ # ✅ API server main (implemented)
│ ├── migrate/ # ✅ Database migration tool (implemented)
│ ├── scheduler/ # 📋 Task scheduler main (planned - Epic 2)
│ └── executor/ # 📋 Task executor main (planned - Epic 2)
│ └── scheduler/ # ✅ Scheduler service main (implemented - for future distributed mode)
├── internal/ # Private application code
│ ├── api/ # ✅ API handlers and routes (implemented)
│ ├── auth/ # ✅ Authentication logic (implemented)
│ ├── config/ # ✅ Configuration management (implemented)
│ ├── database/ # ✅ Database layer (implemented)
│ ├── models/ # ✅ Data models (implemented)
│ ├── services/ # ✅ Business logic services (implemented)
│ ├── executor/ # 📋 Task execution engine (planned - Epic 2)
│ ├── queue/ # 📋 Message queue integration (planned - Epic 2)
│ └── security/ # 📋 Security utilities (planned - Epic 2)
│ ├── executor/ # Task execution engine (implemented)
│ ├── queue/ # ✅ Redis queue integration (implemented)
│ └── worker/ # ✅ Worker management (implemented)
├── pkg/ # Public libraries
│ ├── logger/ # ✅ Structured logging (implemented)
│ ├── metrics/ # 📋 Prometheus metrics (planned - Epic 2)
│ └── utils/ # 📋 Shared utilities (planned)
│ ├── utils/ # ✅ Shared utilities (implemented)
│ └── metrics/ # 📋 Prometheus metrics (planned - Epic 4)
├── api/ # ✅ API specifications (OpenAPI) (implemented)
├── migrations/ # ✅ Database migrations (implemented)
├── tests/ # ✅ Integration tests (implemented)
Expand All @@ -63,11 +65,12 @@ voidrunner/
- Comprehensive testing suite
- OpenAPI documentation

**Epic 2: Container Execution Engine** 🔄 **In Development**
- Docker client integration with security
**Epic 2: Container Execution Engine** **Complete**
- Docker client integration with security controls
- Task execution workflow and state management
- Real-time log collection and streaming
- Error handling and cleanup mechanisms
- Embedded worker pool with concurrency management
- Redis-based queue system with retry logic
- Health monitoring and cleanup mechanisms

**Epic 3: Frontend Interface** 📋 **Planned**
- Svelte project setup and architecture
Expand All @@ -76,11 +79,54 @@ voidrunner/
- Real-time task status updates

**Epic 4: Advanced Features** 📋 **Planned**
- Distributed services architecture (Issue #46)
- Real-time log collection and streaming (Issue #11)
- Enhanced error handling mechanisms (Issue #12)
- Collaborative features and sharing
- Advanced search and filtering
- Real-time dashboard and system metrics
- Advanced notifications and alerting

## GitHub Issues Progress Tracking

### Epic 1: Core API Infrastructure ✅ **Complete**
- **Issue #3**: PostgreSQL Database Setup and Schema Design ✅ **Closed**
- **Issue #4**: JWT Authentication System Implementation ✅ **Closed**
- **Issue #5**: Task Management API Endpoints ✅ **Closed**
- **Issue #6**: API Documentation and Testing Infrastructure ✅ **Closed**

### Epic 2: Container Execution Engine ✅ **Complete**
- **Issue #9**: Docker Client Integration and Security Configuration ✅ **Closed**
- **Issue #10**: Task Execution Workflow and State Management ✅ **Closed**

**Epic 2 Enhancements** (Non-blocking improvements)
- **Issue #11**: Log Collection and Real-time Streaming 📋 **Open** (Priority 1)
- **Issue #12**: Error Handling and Cleanup Mechanisms 📋 **Open** (Priority 2)

> **Note**: Issues #11-12 are enhancements to the completed Epic 2 functionality, not blockers. The core container execution engine with embedded workers is fully operational.

### Epic 3: Frontend Interface 📋 **Ready to Start**
- **Issue #22**: Frontend Interface 📋 **Open**
- **Issue #23**: Svelte Project Setup and Architecture 📋 **Open** (Priority 0)
- **Issue #24**: Authentication UI and User Management 📋 **Open** (Priority 0)
- **Issue #25**: Task Creation and Management Interface 📋 **Open** (Priority 0)
- **Issue #26**: Real-time Task Status Updates 📋 **Open** (Priority 0)
- **Issue #27**: Real-time Features 📋 **Open**

### Epic 4: Advanced Features 📋 **Future Work**
- **Issue #28**: Real-time Dashboard and System Metrics 📋 **Open** (Priority 0)
- **Issue #29**: Advanced Notifications and Alerting 📋 **Open** (Priority 1)
- **Issue #30**: Advanced Search and Filtering 📋 **Open** (Priority 1)
- **Issue #31**: Collaborative Features and Sharing 📋 **Open** (Priority 2)

### Future Enhancements
- **Issue #46**: Separate API and Worker Services for Horizontal Scaling 📋 **Open**
- This epic will transition from embedded workers to distributed services
- Currently tracked for future implementation when scaling requirements emerge

### Current Focus
With Epic 1-2 complete, the project has a fully functional task execution platform with embedded workers. The next logical step is Epic 3 (Frontend Interface) to provide a web-based user interface, followed by Epic 4 advanced features and eventual transition to distributed services (Issue #46).

### Coding Standards

#### 1. Naming Conventions
Expand Down
79 changes: 34 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ VoidRunner is designed to safely execute user-submitted code in isolated contain
- **REST API**: Comprehensive HTTP API with 16+ endpoints for complete task lifecycle management
- **JWT Authentication**: Secure user authentication with access and refresh tokens
- **Task Management**: Full CRUD operations for code tasks with metadata support
- **Task Execution**: Asynchronous task execution with embedded or distributed worker architecture
- **Task Execution**: Asynchronous task execution with embedded worker architecture
- **Container Security**: Docker-based execution with seccomp, resource limits, and isolation
- **Queue System**: Redis-based task queuing with priority support and retry logic
- **Worker Management**: Embedded worker pool with concurrency controls and health monitoring
- **Real-time Monitoring**: Health checks, worker status endpoints, and execution metrics
- **Flexible Deployment**: Embedded workers for development or separate services for production
- **Database Integration**: PostgreSQL with optimized schema and cursor pagination
- **Security**: Input validation, rate limiting, and secure request handling
- **Testing**: 80%+ code coverage with unit and integration tests
- **Documentation**: OpenAPI/Swagger specifications with comprehensive examples

## System Architecture

### Embedded Workers (Development/Small Scale) ✅ Complete
### Current Implementation (Embedded Workers)
Single-process architecture with embedded worker pool for development and production

```
┌─────────────────┐ ┌─────────────────────────────────┐ ┌─────────────────┐
│ Web Clients │ │ API Server │ │ PostgreSQL │
Expand All @@ -37,41 +39,24 @@ VoidRunner is designed to safely execute user-submitted code in isolated contain
│ │ - Task Processing │ │ │ │
│ │ - Docker Execution │ │ └─────────────────┘
│ │ - Health Monitoring │ │
│ │ - Concurrency Control │ │
│ └─────────────────────────┘ │ ┌─────────────────┐
└─────────────────────────────────┘◄──►│ Docker │
│ (Containers) │
│ │
└─────────────────┘
│ (Containers) │
│ │
└─────────────────┘
```

### Distributed Services (Production/Scale) ✅ Complete
```
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Web Clients │ │ API Server │ │ PostgreSQL │ │ Redis │
│ (Postman/curl) │◄──►│ - HTTP API │◄──►│ Database │◄──►│ (Queues) │
│ │ │ - Auth │ │ │ │ │
└─────────────────┘ │ - Task Mgmt │ └─────────────────┘ └─────────────────┘
└──────────────────┘ ▲
┌──────────────────┐ ┌─────────────────┐ │
│ Scheduler Service│◄──►│ Docker │ │
│ - Worker Pools │ │ (Containers) │ │
│ - Task Execution│ │ │ │
│ - Auto-scaling │ └─────────────────┘ │
└──────────────────┘ │
▲ │
└─────────────────────────────────────────────┘
```

### Future Extensions (📋 Roadmap)
### Future Roadmap
- **Distributed Services**: Separate API and worker services for horizontal scaling
- **Svelte Web UI**: Modern frontend interface
- **Kubernetes Deployment**: Container orchestration
- **Multi-language Support**: Additional runtime environments
- **Real-time Collaboration**: Shared workspaces and live editing

## Quick Start

### Development Mode (Embedded Workers)
### Development Mode

The fastest way to get started with VoidRunner:

Expand All @@ -91,28 +76,30 @@ This starts VoidRunner with embedded workers on http://localhost:8080
- Worker Status: http://localhost:8080/health/workers
- API Documentation: http://localhost:8080/docs

### Production Mode (Distributed Services)
### Production Mode

For production deployments with horizontal scaling:
For production deployments:

```bash
# Using Docker Compose
./scripts/docker-deploy.sh -m prod up
docker-compose -f docker-compose.yml up -d

# Or manually
SERVER_ENV=production EMBEDDED_WORKERS=false ./bin/api
SERVER_ENV=production ./bin/scheduler
# Or build and run manually
make build
SERVER_ENV=production ./bin/api
```

### Configuration Modes

VoidRunner supports three deployment configurations:
VoidRunner currently supports embedded worker architecture:

> **Note**: Distributed services (Issue #46) planned for future horizontal scaling needs

| Mode | Use Case | Workers | Scaling | Setup |
|------|----------|---------|---------|-------|
| **Development** | Local development | Embedded | Single process | `EMBEDDED_WORKERS=true` |
| **Production** | Enterprise deployment | Separate service | Horizontal | `EMBEDDED_WORKERS=false` |
| **Test** | CI/CD and testing | Embedded | Single process | `SERVER_ENV=test` |
| Mode | Use Case | Workers | Configuration |
|------|----------|---------|---------------|
| **Development** | Local development | Embedded | Relaxed security, debug logging |
| **Production** | Production deployment | Embedded | Enhanced security, structured logging |
| **Test** | CI/CD and testing | Embedded | Mock executors, test database |

## API Endpoints

Expand All @@ -138,7 +125,8 @@ VoidRunner supports three deployment configurations:
- `DELETE /api/v1/executions/{id}` - Cancel execution

### System Health
- `GET /health` - Health check endpoint
- `GET /health` - API health check endpoint
- `GET /health/workers` - Embedded worker status and metrics
- `GET /ready` - Readiness check endpoint

## Quick Start
Expand All @@ -147,7 +135,8 @@ VoidRunner supports three deployment configurations:

- Go 1.24.4+ installed
- PostgreSQL 15+ (for database operations)
- Docker (for containerization and testing)
- Redis 7+ (for task queuing)
- Docker (for containerization and task execution)

### Setup

Expand Down Expand Up @@ -245,14 +234,14 @@ make docs-serve
### Phase 1: Core Infrastructure ✅ Complete
Task management API with authentication, database integration, and comprehensive testing.

### Phase 2: Container Execution Engine 🔄 In Development
Secure Docker-based code execution with resource limiting, real-time log streaming, and safety controls.
### Phase 2: Container Execution Engine ✅ Complete
Secure Docker-based code execution with embedded workers, resource limiting, and safety controls.

### Phase 3: Web Interface 📋 Planned
Modern Svelte-based frontend with real-time task monitoring, code editor, and user dashboard.

### Phase 4: Advanced Features 📋 Planned
Collaborative features, advanced search and filtering, system metrics dashboard, and notification system.
Distributed services, collaborative features, advanced search and filtering, and real-time log streaming.

## Configuration

Expand All @@ -276,4 +265,4 @@ Please ensure all tests pass and maintain code coverage above 80%.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.