Successfully integrated GitHub Actions runner autoscaling into the unified ipfs-accelerate architecture, using the same Docker provisioning methods across all interfaces.
All requirements from the problem statement have been fulfilled:
✅ Continue finishing unified and MCP server architecture
✅ Integrate GitHub Actions runner autoscaling
✅ Use same Docker container provisioning methods
✅ Expose through CLI, MCP server, and JavaScript SDK
File: ipfs_accelerate_py/kit/runner_kit.py
Classes:
RunnerKit- Main autoscaler classRunnerConfig- Configuration dataclassWorkflowQueue- Workflow queue informationRunnerStatus- Runner container statusAutoscalerStatus- Autoscaler status
Key Features:
- Workflow queue monitoring via github_kit
- Runner token generation via GitHub API
- Container provisioning via docker_kit
- Automatic scaling logic
- Status tracking and reporting
- Cleanup automation
Integration:
- Uses
docker_kit.pyfor all Docker operations - Uses
github_kit.pyfor all GitHub operations - Pure Python, no CLI dependencies
- Fully testable and reusable
File: ipfs_accelerate_py/unified_cli.py (updated)
7 Commands Added:
ipfs-accelerate runner start # Start autoscaler
ipfs-accelerate runner stop # Stop autoscaler
ipfs-accelerate runner status # Get status
ipfs-accelerate runner list-workflows # List workflow queues
ipfs-accelerate runner list-containers # List active containers
ipfs-accelerate runner provision # Manually provision runners
ipfs-accelerate runner stop-container # Stop specific containerFile: ipfs_accelerate_py/mcp/unified_tools.py (updated)
7 Tools Added:
runner_start_autoscaler- Start autoscalingrunner_stop_autoscaler- Stop autoscalingrunner_get_status- Get autoscaler statusrunner_list_workflows- List workflow queuesrunner_provision_for_workflow- Provision for specific reporunner_list_containers- List runner containersrunner_stop_container- Stop specific container
Files:
docs/RUNNER_AUTOSCALING_GUIDE.md(480+ lines) - Complete user guidedocs/UNIFIED_ARCHITECTURE.md(updated, +100 lines) - Architecture documentation
Coverage:
- Overview and architecture
- Three usage interfaces (CLI, MCP, Python)
- Configuration reference
- Docker provisioning details
- Security considerations
- Monitoring and troubleshooting
- Migration guide
- Complete examples
┌──────────────────────────────────────────────────────┐
│ ipfs_accelerate_py/kit/runner_kit.py │
│ (Core autoscaling logic - 630 lines) │
│ │
│ ├─ Uses docker_kit.py (container operations) │
│ └─ Uses github_kit.py (GitHub operations) │
└─────────────┬────────────────────────────────────────┘
│
┌───────┴────────┐
↓ ↓
┌─────────────┐ ┌──────────────────────────┐
│ unified_cli │ │ mcp/unified_tools.py │
│ (7 commands)│ │ (7 MCP tools) │
└─────────────┘ └──────────┬───────────────┘
↓
┌──────────────────────────┐
│ MCP Server │
└──────────┬───────────────┘
↓
┌──────────────────────────┐
│ JavaScript SDK │
└──────────┬───────────────┘
↓
┌──────────────────────────┐
│ Dashboard │
└──────────────────────────┘
Problem: Standalone autoscaler and runner launcher had their own Docker implementations, causing code duplication.
Solution: Runner module uses docker_kit.py for all container operations:
docker_kit.run_container()for launching runnersdocker_kit.list_containers()for monitoringdocker_kit.stop_container()for cleanup
Result:
- Zero code duplication
- Consistent behavior
- Single source of truth
- Easier to maintain
Problem: Autoscaler was only accessible via standalone script.
Solution: Integrated into unified architecture with three interfaces:
CLI (for manual management):
ipfs-accelerate runner start --owner myorgMCP (for programmatic access):
await mcp.call_tool('runner_start_autoscaler', {owner: 'myorg'});Python API (for custom integration):
from ipfs_accelerate_py.kit.runner_kit import get_runner_kit
kit = get_runner_kit()
kit.start_autoscaler()Problem: No way to monitor or control autoscaler from dashboard.
Solution: All 7 runner tools exposed through MCP server:
- Start/stop autoscaler from dashboard
- View real-time status and metrics
- Monitor workflow queues
- Manage runner containers
- Provision runners on-demand
# Start monitoring all accessible repos
ipfs-accelerate runner start --background
# Check status
ipfs-accelerate runner status
# View workflow queues
ipfs-accelerate runner list-workflows
# Stop when done
ipfs-accelerate runner stop# Monitor specific organization
ipfs-accelerate runner start \
--owner myorg \
--interval 60 \
--max-runners 20 \
--background// Start autoscaler
const result = await mcp.call_tool('runner_start_autoscaler', {
owner: 'myorg',
poll_interval: 60,
max_runners: 20,
background: true
});
// Get real-time status
const status = await mcp.call_tool('runner_get_status', {});
console.log(`Active runners: ${status.data.active_runners}`);
console.log(`Queued workflows: ${status.data.queued_workflows}`);
// List workflow queues
const workflows = await mcp.call_tool('runner_list_workflows', {});
workflows.data.forEach(queue => {
console.log(`${queue.repo}: ${queue.total_workflows} workflows`);
});from ipfs_accelerate_py.kit.runner_kit import get_runner_kit, RunnerConfig
# Create config
config = RunnerConfig(
owner='myorg',
max_runners=20,
poll_interval=60
)
# Initialize
kit = get_runner_kit(config)
# Start autoscaler in background
kit.start_autoscaler(background=True)
# Custom logic: provision extra for priority repos
priority_repos = ['owner/critical-app']
queues = kit.get_workflow_queues()
for queue in queues:
if queue.repo in priority_repos and queue.pending > 0:
token = kit.generate_runner_token(queue.repo)
container_id = kit.launch_runner_container(queue.repo, token)
print(f"Provisioned priority runner: {container_id}")| Component | Lines | Description |
|---|---|---|
| runner_kit.py | 630 | Core module |
| unified_cli.py | +160 | CLI commands |
| unified_tools.py | +270 | MCP tools |
| Total Code | 1,060 | Production code |
| Document | Lines | Description |
|---|---|---|
| RUNNER_AUTOSCALING_GUIDE.md | 480 | User guide |
| UNIFIED_ARCHITECTURE.md | +100 | Architecture updates |
| Total Docs | 580 | Comprehensive guides |
| Category | Count | Description |
|---|---|---|
| CLI Commands | 7 | ipfs-accelerate runner commands |
| MCP Tools | 7 | Programmatic access |
| Python Classes | 5 | Core classes |
| Total | 19 | New interfaces |
✅ Single Source of Truth: All logic in runner_kit.py
✅ Code Reuse: Uses docker_kit and github_kit
✅ Easy Testing: Pure Python module
✅ Type Safety: Full type hints throughout
✅ Well Documented: Comprehensive guides
✅ Unified Interface: Same pattern as other ipfs-accelerate commands
✅ Multiple Access Methods: CLI, MCP, Python API
✅ Dashboard Integration: Real-time monitoring and control
✅ Easy Migration: Compatible with existing scripts
✅ Comprehensive Documentation: Complete user guide
✅ Consistent Behavior: Same Docker provisioning everywhere
✅ Security Built-in: Container isolation, resource limits
✅ Monitoring: Real-time status and metrics
✅ Automation: Programmable via MCP tools
✅ Troubleshooting: Detailed logging and error handling
✅ Type Hints: Full typing throughout
✅ Error Handling: Comprehensive error handling
✅ Logging: Detailed logging at all levels
✅ Documentation: 580+ lines of guides
✅ Examples: Complete usage examples
✅ Security: Container isolation and resource limits
✅ CLI: All 7 commands tested
✅ MCP: All 7 tools registered and functional
✅ Python API: Direct import and usage tested
✅ Docker Kit: Integration verified
✅ GitHub Kit: Integration verified
-
User Guide:
docs/RUNNER_AUTOSCALING_GUIDE.md- Complete feature documentation
- Three usage interfaces
- Configuration reference
- Troubleshooting guide
- Migration guide
-
Architecture:
docs/UNIFIED_ARCHITECTURE.md- System architecture
- Integration points
- Design patterns
- Migration path
-
API Reference:
ipfs_accelerate_py/kit/runner_kit.py- Complete docstrings
- Type hints
- Usage examples
Before:
python scripts/utils/github_autoscaler.py --owner myorg --interval 60After:
Option 1 - CLI:
ipfs-accelerate runner start --owner myorg --interval 60Option 2 - Python:
from ipfs_accelerate_py.kit.runner_kit import get_runner_kit, RunnerConfig
kit = get_runner_kit(RunnerConfig(owner='myorg', poll_interval=60))
kit.start_autoscaler()Option 3 - MCP/JavaScript:
await mcp.call_tool('runner_start_autoscaler', {
owner: 'myorg',
poll_interval: 60
});✅ Unified interface with other ipfs-accelerate commands
✅ Code reuse (docker_kit, github_kit)
✅ MCP integration for dashboard access
✅ Better testing capabilities
✅ Consistent behavior across system
✅ Comprehensive documentation
All requirements have been met:
- ✅ Unified Architecture - Runner module follows established pattern
- ✅ Docker Provisioning - Uses same methods as all other Docker operations
- ✅ Multi-Interface - Available via CLI, MCP, and Python API
- ✅ Dashboard Ready - Full MCP integration for JavaScript SDK
- ✅ Well Documented - 580+ lines of comprehensive guides
- ✅ Production Ready - Tested, secure, and fully functional
A complete GitHub Actions runner autoscaling system that:
- Monitors workflow queues across repositories
- Automatically provisions runners as Docker containers
- Uses unified Docker provisioning methods
- Provides three access interfaces (CLI, MCP, Python)
- Integrates with dashboard via JavaScript SDK
- Includes comprehensive documentation
- Follows established architecture patterns
The runner module demonstrates the power of the unified architecture:
- Adding new functionality automatically provides CLI commands
- MCP tools are created alongside
- Python API is available by default
- Everything shares the same underlying implementation
- Documentation follows established patterns
This approach makes it easy to add new features while maintaining consistency and quality across the entire system.
For issues or questions:
- Check
docs/RUNNER_AUTOSCALING_GUIDE.mdtroubleshooting section - Review logs with
--verboseflag - Verify Docker and GitHub CLI are working
- Check GitHub repository issues
Implementation Complete: January 2024 Status: Production Ready Architecture: Unified ipfs-accelerate pattern