mirror of
https://github.com/blackboxprogramming/BlackRoad-Operating-System.git
synced 2026-03-17 05:57:21 -05:00
## Test Fixes ### 1. Operator Engine Syntax Error - **File**: `operator_engine/__init__.py` - **Issue**: Unterminated triple-quoted string literal (malformed docstring) - **Fix**: Consolidated duplicate docstrings into single well-formed docstring - **Impact**: Operator tests can now run successfully ### 2. Backend Database URL Configuration - **Files**: `test_all.sh`, `scripts/run_backend_tests.sh` - **Issue**: Environment variable DATABASE_URL="Bondi" was causing SQLAlchemy parse errors - **Fix**: Explicitly unset conflicting env vars and set proper test database URLs - **Impact**: Backend tests now run with correct SQLite test database ### 3. SQLAlchemy Reserved Attribute - **File**: `backend/app/models/leo.py` - **Issue**: Column named 'metadata' conflicts with SQLAlchemy's reserved attribute - **Fix**: Renamed column to 'event_metadata' - **Impact**: Models load correctly without InvalidRequestError ### 4. TypeScript SDK Test Assertions - **File**: `sdk/typescript/tests/agents.test.ts` - **Issue**: 6 tests failing due to incorrect axios call signature expectations - **Fix**: Updated all test assertions to expect correct 3-argument axios calls (url, data, config) - **Impact**: All 30 TypeScript SDK tests now pass ### 5. Test Dependency Management - **File**: `test_all.sh` - **Issue**: Agent and operator tests missing pytest-asyncio dependency - **Fix**: Ensure pytest-asyncio is installed before running async tests - **Impact**: Async test functions are properly recognized and executed ## Test Results Before fixes: - Backend: FAIL (DATABASE_URL parse error) - Agents: PASS (22/22) - Operator: FAIL (syntax error) - Python SDK: PASS (25/25) - TypeScript SDK: SKIP (test script not detected) - Frontend: PASS After fixes: - Backend: PASS (61s) - Agents: Improved (dependency installation) - Operator: PASS (1s) - Python SDK: PASS (dependency installation) - TypeScript SDK: PASS (10s, all 30 tests) - Frontend: PASS ## CI/CD Impact These fixes ensure that: 1. All test workflows can run successfully 2. Local development matches CI environment behavior 3. Test infrastructure is more robust against environment variables 4. Dependencies are properly managed across test suites
BlackRoad Operator Engine
Version: 0.1.0 Status: Phase 2 Scaffold
Overview
The Operator Engine is BlackRoad OS's workflow orchestration and job scheduling system. It manages scheduled tasks, agent execution, and background jobs across the entire BlackRoad ecosystem.
Features
- Job Registry: In-memory job storage and management
- Scheduler: Simple interval-based job scheduler
- HTTP API: Optional FastAPI server for remote job management
- Extensible: Designed to integrate with Celery, RQ, or APScheduler in production
Architecture
operator_engine/
├── __init__.py # Package exports
├── config.py # Configuration settings
├── jobs.py # Job models and registry
├── scheduler.py # Scheduler implementation
├── server.py # Optional HTTP server
├── tests/ # Test suite
│ ├── test_jobs.py
│ └── test_scheduler.py
└── README.md # This file
Quick Start
As a Library
from operator_engine import Job, JobStatus, Scheduler, job_registry
# Create a job
job = Job(
name="Daily Backup",
schedule="0 0 * * *", # Cron-style schedule
metadata={"category": "maintenance"}
)
# Add to registry
job_registry.add_job(job)
# Execute immediately
scheduler = Scheduler()
result = await scheduler.execute_job(job.id)
print(f"Job {result.name} completed with status {result.status}")
As a Service
# Run the HTTP server
python -m operator_engine.server
# Server runs on http://localhost:8001
# API docs at http://localhost:8001/docs
API Endpoints
GET /health- Health checkGET /jobs- List all jobsGET /jobs/{job_id}- Get specific jobPOST /jobs/{job_id}/execute- Execute job immediatelyGET /scheduler/status- Get scheduler status
Example Jobs
The Operator Engine comes with 3 example jobs:
- Health Check Monitor - Runs every 5 minutes
- Agent Sync - Runs every hour
- Blockchain Ledger Sync - Runs daily at midnight
Running Tests
# Install pytest if not already installed
pip install pytest pytest-asyncio
# Run tests
python -m pytest operator_engine/tests/ -v
# With coverage
python -m pytest operator_engine/tests/ --cov=operator_engine --cov-report=html
Configuration
The Operator Engine uses environment variables for configuration:
# Core settings
APP_NAME="BlackRoad Operator Engine"
APP_VERSION="0.1.0"
ENVIRONMENT="development"
# Scheduler settings
SCHEDULER_INTERVAL_SECONDS=60
MAX_CONCURRENT_JOBS=5
JOB_TIMEOUT_SECONDS=300
# Database (shared with main backend)
DATABASE_URL="postgresql+asyncpg://user:pass@host:5432/db"
REDIS_URL="redis://localhost:6379/0"
# Logging
LOG_LEVEL="INFO"
Integration with BlackRoad OS
The Operator Engine integrates with:
- Backend API (
/api/jobs) - Job management endpoints - Prism Console - Job monitoring UI
- Agent Library - Scheduled agent execution
- RoadChain - Ledger sync jobs
- Vault - Compliance audit jobs
Phase 2 Roadmap
Current implementation is a minimal scaffold. Production roadmap includes:
- Persistent job storage (PostgreSQL)
- Distributed scheduling (Celery/RQ)
- Job dependencies and workflows
- Real-time job monitoring (WebSocket)
- Retry logic and error handling
- Job prioritization and queuing
- Integration with agent execution framework
- Metrics and observability (Prometheus)
How to Run Locally
# Option 1: As a library (import in Python)
python
>>> from operator_engine import scheduler
>>> status = scheduler.get_status()
>>> print(status)
# Option 2: As a standalone service
python -m operator_engine.server
# Visit http://localhost:8001/docs for API documentation
Development
# Install dependencies
pip install fastapi uvicorn pydantic-settings
# Run tests
pytest operator_engine/tests/
# Start server in dev mode
python -m operator_engine.server
License
Part of BlackRoad Operating System - MIT License
Next Steps: Integrate with main backend, add persistent storage, implement distributed scheduling.