docs: add code quality and type checking workflows to master index
Some checks failed
Documentation Validation / validate-docs (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
API Endpoint Tests / test-api-endpoints (push) Has been cancelled
CLI Tests / test-cli (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Package Tests / test-python-packages (map[name:aitbc-agent-sdk path:packages/py/aitbc-agent-sdk]) (push) Has been cancelled
Package Tests / test-python-packages (map[name:aitbc-core path:packages/py/aitbc-core]) (push) Has been cancelled
Package Tests / test-python-packages (map[name:aitbc-crypto path:packages/py/aitbc-crypto]) (push) Has been cancelled
Package Tests / test-python-packages (map[name:aitbc-sdk path:packages/py/aitbc-sdk]) (push) Has been cancelled
Package Tests / test-javascript-packages (map[name:aitbc-sdk-js path:packages/js/aitbc-sdk]) (push) Has been cancelled
Package Tests / test-javascript-packages (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Systemd Sync / sync-systemd (push) Has been cancelled

- Add Code Quality Module section with pre-commit hooks and quality checks
- Add Type Checking CI/CD Module section with MyPy workflow and coverage
- Update README with code quality achievements and project structure
- Migrate FastAPI apps from deprecated on_event to lifespan context manager
- Update pyproject.toml files to reference consolidated dependencies
- Remove unused app.py import in coordinator-api
- Add type hints to agent
This commit is contained in:
aitbc
2026-03-31 21:45:43 +02:00
parent 26592ddf55
commit 9db720add8
308 changed files with 34194 additions and 34575 deletions

3
scripts/aitbc-cli Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
source /opt/aitbc/venv/bin/activate
python /opt/aitbc/cli/aitbc_cli.py "$@"

1
scripts/aitbc-miner Symbolic link
View File

@@ -0,0 +1 @@
/opt/aitbc/cli/miner_cli.py

View File

@@ -0,0 +1,325 @@
#!/bin/bash
# AITBC Dependency Management Script
# Consolidates and updates dependencies across all services
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Main directory
AITBC_ROOT="/opt/aitbc"
cd "$AITBC_ROOT"
# Backup current requirements
backup_requirements() {
log_info "Creating backup of current requirements..."
timestamp=$(date +%Y%m%d_%H%M%S)
backup_dir="backups/dependency_backup_$timestamp"
mkdir -p "$backup_dir"
# Backup all requirements files
find . -name "requirements*.txt" -not -path "./venv/*" -exec cp {} "$backup_dir/" \;
find . -name "pyproject.toml" -not -path "./venv/*" -exec cp {} "$backup_dir/" \;
log_success "Backup created in $backup_dir"
}
# Update central requirements
update_central_requirements() {
log_info "Updating central requirements..."
# Install consolidated dependencies
if [ -f "requirements-consolidated.txt" ]; then
log_info "Installing consolidated dependencies..."
./venv/bin/pip install -r requirements-consolidated.txt
log_success "Consolidated dependencies installed"
else
log_error "requirements-consolidated.txt not found"
return 1
fi
}
# Update service-specific pyproject.toml files
update_service_configs() {
log_info "Updating service configurations..."
# List of services to update
services=(
"apps/coordinator-api"
"apps/blockchain-node"
"apps/pool-hub"
"apps/wallet"
)
for service in "${services[@]}"; do
if [ -f "$service/pyproject.toml" ]; then
log_info "Updating $service..."
# Create a simplified pyproject.toml that references central dependencies
cat > "$service/pyproject.toml" << EOF
[tool.poetry]
name = "$(basename "$service")"
version = "v0.2.3"
description = "AITBC $(basename "$service") service"
authors = ["AITBC Team"]
[tool.poetry.dependencies]
python = "^3.13"
# All dependencies managed centrally in /opt/aitbc/requirements-consolidated.txt
[tool.poetry.group.dev.dependencies]
# Development dependencies managed centrally
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
EOF
log_success "Updated $service/pyproject.toml"
fi
done
}
# Update CLI requirements
update_cli_requirements() {
log_info "Updating CLI requirements..."
if [ -f "cli/requirements-cli.txt" ]; then
# Create minimal CLI requirements (others from central)
cat > "cli/requirements-cli.txt" << EOF
# AITBC CLI Requirements
# Core CLI-specific dependencies (others from central requirements)
# CLI Enhancement Dependencies
click>=8.1.0
rich>=13.0.0
tabulate>=0.9.0
colorama>=0.4.4
keyring>=23.0.0
click-completion>=0.5.2
typer>=0.12.0
# Note: All other dependencies are managed in /opt/aitbc/requirements-consolidated.txt
EOF
log_success "Updated CLI requirements"
fi
}
# Create installation profiles script
create_profiles() {
log_info "Creating installation profiles..."
cat > "scripts/install-profiles.sh" << 'EOF'
#!/bin/bash
# AITBC Installation Profiles
# Install specific dependency sets for different use cases
set -euo pipefail
AITBC_ROOT="/opt/aitbc"
cd "$AITBC_ROOT"
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
# Installation profiles
install_web() {
log_info "Installing web profile..."
./venv/bin/pip install fastapi uvicorn gunicorn starlette
}
install_database() {
log_info "Installing database profile..."
./venv/bin/pip install sqlalchemy sqlmodel alembic aiosqlite asyncpg
}
install_blockchain() {
log_info "Installing blockchain profile..."
./venv/bin/pip install cryptography pynacl ecdsa base58 bech32 web3 eth-account
}
install_ml() {
log_info "Installing ML profile..."
./venv/bin/pip install torch torchvision numpy pandas
}
install_cli() {
log_info "Installing CLI profile..."
./venv/bin/pip install click rich typer click-completion tabulate colorama keyring
}
install_monitoring() {
log_info "Installing monitoring profile..."
./venv/bin/pip install structlog sentry-sdk prometheus-client
}
install_image() {
log_info "Installing image processing profile..."
./venv/bin/pip install pillow opencv-python
}
install_all() {
log_info "Installing all profiles..."
./venv/bin/pip install -r requirements-consolidated.txt
}
install_minimal() {
log_info "Installing minimal profile..."
./venv/bin/pip install fastapi pydantic python-dotenv
}
# Main menu
case "${1:-all}" in
"web")
install_web
;;
"database")
install_database
;;
"blockchain")
install_blockchain
;;
"ml")
install_ml
;;
"cli")
install_cli
;;
"monitoring")
install_monitoring
;;
"image")
install_image
;;
"all")
install_all
;;
"minimal")
install_minimal
;;
*)
echo "Usage: $0 {web|database|blockchain|ml|cli|monitoring|image|all|minimal}"
echo ""
echo "Profiles:"
echo " web - Web framework dependencies"
echo " database - Database and ORM dependencies"
echo " blockchain - Cryptography and blockchain dependencies"
echo " ml - Machine learning dependencies"
echo " cli - CLI tool dependencies"
echo " monitoring - Logging and monitoring dependencies"
echo " image - Image processing dependencies"
echo " all - All dependencies (default)"
echo " minimal - Minimal set for basic operation"
exit 1
;;
esac
log_success "Installation completed"
EOF
chmod +x "scripts/install-profiles.sh"
log_success "Created installation profiles script"
}
# Validate dependency consistency
validate_dependencies() {
log_info "Validating dependency consistency..."
# Check for conflicts
log_info "Checking for version conflicts..."
conflicts=$(./venv/bin/pip check 2>&1 || true)
if echo "$conflicts" | grep -q "No broken requirements"; then
log_success "No dependency conflicts found"
else
log_warning "Dependency conflicts found:"
echo "$conflicts"
return 1
fi
}
# Generate dependency report
generate_report() {
log_info "Generating dependency report..."
report_file="dependency-report-$(date +%Y%m%d_%H%M%S).txt"
cat > "$report_file" << EOF
AITBC Dependency Report
====================
Generated: $(date)
Consolidated Dependencies:
$(wc -l requirements-consolidated.txt)
Installed Packages:
$(./venv/bin/pip list | wc -l)
Disk Usage:
$(du -sh venv/ | cut -f1)
Security Audit:
$(./venv/bin/safety check --json 2>/dev/null | ./venv/bin/python -c "import json, sys; data=json.load(sys.stdin); print(f'Vulnerabilities: {len(data)}')" 2>/dev/null || echo "Unable to check")
EOF
log_success "Dependency report generated: $report_file"
}
# Main execution
main() {
log_info "Starting AITBC dependency consolidation..."
backup_requirements
update_central_requirements
update_service_configs
update_cli_requirements
create_profiles
if validate_dependencies; then
generate_report
log_success "Dependency consolidation completed successfully!"
echo ""
log_info "Next steps:"
echo "1. Test services with new dependencies"
echo "2. Run './scripts/install-profiles.sh <profile>' for specific installations"
echo "3. Monitor for any dependency-related issues"
else
log_error "Dependency consolidation failed - check conflicts"
exit 1
fi
}
# Run main function
main "$@"

73
scripts/health-check.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/bin/bash
# AITBC Health Check Script
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
check_service() {
local name=$1
local url=$2
local expected=${3:-200}
if curl -s -o /dev/null -w "%{http_code}" "$url" | grep -q "$expected"; then
echo -e "${GREEN}${NC} $name is healthy"
return 0
else
echo -e "${RED}${NC} $name is unhealthy"
return 1
fi
}
echo "AITBC Service Health Check"
echo "========================"
# Core Services (8000-8009)
echo ""
echo "🔧 Core Services (8000-8009):"
check_service "Coordinator API" "http://localhost:8000/health"
check_service "Exchange API" "http://localhost:8001/api/health"
check_service "Marketplace API" "http://localhost:8002/health"
check_service "Wallet API" "http://localhost:8003/health"
check_service "Explorer" "http://localhost:8004/health"
check_service "Web UI" "http://localhost:8007/health"
# Check blockchain node and RPC
echo ""
echo "⛓️ Blockchain Services:"
if systemctl is-active --quiet aitbc-blockchain-node.service; then
echo -e "${GREEN}${NC} Blockchain Node is running"
else
echo -e "${RED}${NC} Blockchain Node is not running"
fi
if systemctl is-active --quiet aitbc-blockchain-rpc.service; then
echo -e "${GREEN}${NC} Blockchain RPC (port 8006) is running"
else
echo -e "${RED}${NC} Blockchain RPC (port 8006) is not running"
fi
# AI/Agent/GPU Services (8010-8019)
echo ""
echo "🚀 AI/Agent/GPU Services (8010-8019):"
check_service "GPU Service" "http://localhost:8010/health"
check_service "Learning Service" "http://localhost:8011/health"
check_service "Agent Coordinator" "http://localhost:8012/health"
check_service "Agent Registry" "http://localhost:8013/health"
check_service "OpenClaw Service" "http://localhost:8014/health"
check_service "AI Service" "http://localhost:8015/health"
# Other Services (8020-8029)
echo ""
echo "📊 Other Services (8020-8029):"
check_service "Multimodal Service" "http://localhost:8020/health"
check_service "Modality Optimization" "http://localhost:8021/health"
# Check process status
echo ""
echo "Process Status:"
ps aux | grep -E "simple_daemon|uvicorn|simple_exchange_api" | grep -v grep | while read line; do
echo -e "${GREEN}${NC} $line"
done

125
scripts/install-profiles.sh Executable file
View File

@@ -0,0 +1,125 @@
#!/bin/bash
# AITBC Installation Profiles
# Install specific dependency sets for different use cases
set -euo pipefail
AITBC_ROOT="/opt/aitbc"
cd "$AITBC_ROOT"
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
# Installation profiles
install_web() {
log_info "Installing web profile..."
./venv/bin/pip install fastapi==0.115.6 uvicorn[standard]==0.32.1 gunicorn==22.0.0 "starlette>=0.40.0,<0.42.0"
}
install_database() {
log_info "Installing database profile..."
./venv/bin/pip install sqlalchemy==2.0.47 sqlmodel==0.0.37 alembic==1.18.0 aiosqlite==0.20.0 asyncpg==0.29.0
}
install_blockchain() {
log_info "Installing blockchain profile..."
./venv/bin/pip install cryptography==46.0.0 pynacl==1.5.0 ecdsa==0.19.0 base58==2.1.1 bech32==1.2.0 web3==6.11.0 eth-account==0.13.0
}
install_ml() {
log_info "Installing ML profile..."
./venv/bin/pip install torch==2.10.0 torchvision==0.15.0 numpy==1.26.0 pandas==2.2.0
}
install_cli() {
log_info "Installing CLI profile..."
./venv/bin/pip install click==8.1.0 rich==13.0.0 typer==0.12.0 click-completion==0.5.2 tabulate==0.9.0 colorama==0.4.4 keyring==23.0.0
}
install_monitoring() {
log_info "Installing monitoring profile..."
./venv/bin/pip install structlog==24.1.0 sentry-sdk==2.0.0 prometheus-client==0.24.0
}
install_image() {
log_info "Installing image processing profile..."
./venv/bin/pip install pillow==10.0.0 opencv-python==4.9.0
}
install_all() {
log_info "Installing all profiles..."
if [ -f "requirements-consolidated.txt" ]; then
./venv/bin/pip install -r requirements-consolidated.txt
else
log_info "Installing profiles individually..."
install_web
install_database
install_blockchain
install_cli
install_monitoring
# ML and Image processing are optional - install separately if needed
fi
}
install_minimal() {
log_info "Installing minimal profile..."
./venv/bin/pip install fastapi==0.115.6 pydantic==2.12.0 python-dotenv==1.2.0
}
# Main menu
case "${1:-all}" in
"web")
install_web
;;
"database")
install_database
;;
"blockchain")
install_blockchain
;;
"ml")
install_ml
;;
"cli")
install_cli
;;
"monitoring")
install_monitoring
;;
"image")
install_image
;;
"all")
install_all
;;
"minimal")
install_minimal
;;
*)
echo "Usage: $0 {web|database|blockchain|ml|cli|monitoring|image|all|minimal}"
echo ""
echo "Profiles:"
echo " web - Web framework dependencies"
echo " database - Database and ORM dependencies"
echo " blockchain - Cryptography and blockchain dependencies"
echo " ml - Machine learning dependencies"
echo " cli - CLI tool dependencies"
echo " monitoring - Logging and monitoring dependencies"
echo " image - Image processing dependencies"
echo " all - All dependencies (default)"
echo " minimal - Minimal set for basic operation"
exit 1
;;
esac
log_success "Installation completed"

367
scripts/setup.sh Executable file
View File

@@ -0,0 +1,367 @@
#!/bin/bash
# AITBC Local Setup Script
# Sets up AITBC services on a new host with systemd
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging function
log() {
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
# Check if running as root
check_root() {
if [ "$EUID" -ne 0 ]; then
error "This script must be run as root (use sudo)"
fi
}
# Check prerequisites
check_prerequisites() {
log "Checking prerequisites..."
# Check if required tools are installed
command -v python3 >/dev/null 2>&1 || error "Python 3 is not installed"
command -v pip3 >/dev/null 2>&1 || error "pip3 is not installed"
command -v git >/dev/null 2>&1 || error "git is not installed"
command -v systemctl >/dev/null 2>&1 || error "systemctl is not available"
command -v node >/dev/null 2>&1 || error "Node.js is not installed"
command -v npm >/dev/null 2>&1 || error "npm is not installed"
# Check Python version
python_version=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')")
if [ "$(printf '%s\n' "3.13.5" "$python_version" | sort -V | head -n1)" != "3.13.5" ]; then
error "Python 3.13.5+ is required, found $python_version"
fi
# Check Node.js version
node_version=$(node -v | sed 's/v//')
if [ "$(printf '%s\n' "24.14.0" "$node_version" | sort -V | head -n1)" != "24.14.0" ]; then
error "Node.js 24.14.0+ is required, found $node_version"
fi
success "Prerequisites check passed"
}
# Clone repository
clone_repo() {
log "Cloning AITBC repository..."
# Check if repository already exists
if [ -d "/opt/aitbc/.git" ]; then
success "AITBC repository already exists, skipping clone"
return 0
fi
# Clone repository
cd /opt
git clone http://gitea.bubuit.net:3000/oib/aitbc.git aitbc || error "Failed to clone repository"
cd /opt/aitbc
success "Repository cloned successfully"
}
# Setup runtime directories
setup_runtime_directories() {
log "Setting up runtime directories..."
# Create standard Linux directories
directories=(
"/var/lib/aitbc"
"/var/lib/aitbc/keystore"
"/var/lib/aitbc/data"
"/var/log/aitbc"
"/etc/aitbc"
)
for dir in "${directories[@]}"; do
mkdir -p "$dir"
log "Created directory: $dir"
done
# Set permissions
chmod 755 /var/lib/aitbc
chmod 700 /var/lib/aitbc/keystore # Secure keystore
chmod 755 /var/lib/aitbc/data
chmod 755 /var/log/aitbc
chmod 755 /etc/aitbc
# Set ownership
chown root:root /var/lib/aitbc
chown root:root /var/lib/aitbc/keystore
chown root:root /var/lib/aitbc/data
chown root:root /var/log/aitbc
chown root:root /etc/aitbc
# Create README files
echo "# AITBC Runtime Data Directory" > /var/lib/aitbc/README.md
echo "# Keystore for blockchain keys (SECURE)" > /var/lib/aitbc/keystore/README.md
echo "# Application databases" > /var/lib/aitbc/data/README.md
echo "# Application logs" > /var/log/aitbc/README.md
echo "# AITBC Configuration Files" > /etc/aitbc/README.md
success "Runtime directories setup completed"
}
# Setup Python virtual environments
setup_venvs() {
log "Setting up Python virtual environments..."
# Create central virtual environment if it doesn't exist
if [ ! -d "/opt/aitbc/venv" ]; then
log "Creating central virtual environment..."
cd /opt/aitbc
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
else
log "Central virtual environment already exists, activating..."
source /opt/aitbc/venv/bin/activate
fi
# Install all dependencies from central requirements.txt
log "Installing all dependencies from central requirements.txt..."
# Install main requirements (contains all service dependencies)
if [ -f "/opt/aitbc/requirements.txt" ]; then
pip install -r /opt/aitbc/requirements.txt
else
error "Main requirements.txt not found"
fi
success "Virtual environments setup completed"
}
# Install systemd services
install_services() {
log "Installing systemd services..."
# Install core services
services=(
"aitbc-wallet.service"
"aitbc-coordinator-api.service"
"aitbc-exchange-api.service"
"aitbc-blockchain-node.service"
"aitbc-blockchain-rpc.service"
"aitbc-gpu.service"
"aitbc-marketplace.service"
"aitbc-openclaw.service"
"aitbc-ai.service"
"aitbc-learning.service"
"aitbc-explorer.service"
"aitbc-web-ui.service"
"aitbc-agent-coordinator.service"
"aitbc-agent-registry.service"
"aitbc-multimodal.service"
"aitbc-modality-optimization.service"
)
for service in "${services[@]}"; do
if [ -f "/opt/aitbc/systemd/$service" ]; then
log "Installing $service..."
ln -sf "/opt/aitbc/systemd/$service" /etc/systemd/system/
else
warning "Service file not found: $service"
fi
done
# Reload systemd
systemctl daemon-reload
success "Systemd services installed"
}
# Create health check script
create_health_check() {
log "Creating health check script..."
cat > /opt/aitbc/health-check.sh << 'EOF'
#!/bin/bash
# AITBC Health Check Script
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
check_service() {
local name=$1
local url=$2
local expected=${3:-200}
if curl -s -o /dev/null -w "%{http_code}" "$url" | grep -q "$expected"; then
echo -e "${GREEN}✓${NC} $name is healthy"
return 0
else
echo -e "${RED}✗${NC} $name is unhealthy"
return 1
fi
}
echo "AITBC Service Health Check"
echo "========================"
# Core Services (8000-8009)
echo ""
echo "🔧 Core Services (8000-8009):"
check_service "Coordinator API" "http://localhost:8000/health"
check_service "Exchange API" "http://localhost:8001/api/health"
check_service "Marketplace API" "http://localhost:8002/health"
check_service "Wallet API" "http://localhost:8003/health"
check_service "Explorer" "http://localhost:8004/health"
check_service "Web UI" "http://localhost:8007/health"
# Check blockchain node and RPC
echo ""
echo "⛓️ Blockchain Services:"
if systemctl is-active --quiet aitbc-blockchain-node.service; then
echo -e "${GREEN}✓${NC} Blockchain Node is running"
else
echo -e "${RED}✗${NC} Blockchain Node is not running"
fi
if systemctl is-active --quiet aitbc-blockchain-rpc.service; then
echo -e "${GREEN}✓${NC} Blockchain RPC (port 8006) is running"
else
echo -e "${RED}✗${NC} Blockchain RPC (port 8006) is not running"
fi
# AI/Agent/GPU Services (8010-8019)
echo ""
echo "🚀 AI/Agent/GPU Services (8010-8019):"
check_service "GPU Service" "http://localhost:8010/health"
check_service "Learning Service" "http://localhost:8011/health"
check_service "Agent Coordinator" "http://localhost:8012/health"
check_service "Agent Registry" "http://localhost:8013/health"
check_service "OpenClaw Service" "http://localhost:8014/health"
check_service "AI Service" "http://localhost:8015/health"
# Other Services (8020-8029)
echo ""
echo "📊 Other Services (8020-8029):"
check_service "Multimodal Service" "http://localhost:8020/health"
check_service "Modality Optimization" "http://localhost:8021/health"
# Check process status
echo ""
echo "Process Status:"
ps aux | grep -E "simple_daemon|uvicorn|simple_exchange_api" | grep -v grep | while read line; do
echo -e "${GREEN}✓${NC} $line"
done
EOF
chmod +x /opt/aitbc/health-check.sh
success "Health check script created"
}
# Start services
start_services() {
log "Starting AITBC services..."
# Try systemd first
if systemctl start aitbc-wallet aitbc-coordinator-api aitbc-exchange-api aitbc-blockchain-node aitbc-blockchain-rpc aitbc-gpu aitbc-marketplace aitbc-openclaw aitbc-ai aitbc-learning aitbc-explorer aitbc-web-ui aitbc-agent-coordinator aitbc-agent-registry aitbc-multimodal aitbc-modality-optimization 2>/dev/null; then
log "Services started via systemd"
sleep 5
# Check if services are running
if systemctl is-active --quiet aitbc-wallet aitbc-coordinator-api aitbc-exchange-api aitbc-blockchain-node aitbc-blockchain-rpc aitbc-gpu aitbc-marketplace aitbc-openclaw aitbc-ai aitbc-learning aitbc-explorer aitbc-web-ui aitbc-agent-coordinator aitbc-agent-registry aitbc-multimodal aitbc-modality-optimization; then
success "Services started successfully via systemd"
else
warning "Some systemd services failed, falling back to manual startup"
/opt/aitbc/start-services.sh
fi
else
log "Systemd services not available, using manual startup"
/opt/aitbc/start-services.sh
fi
# Wait for services to initialize
sleep 10
# Run health check
/opt/aitbc/health-check.sh
}
# Setup auto-start
setup_autostart() {
log "Setting up auto-start..."
# Enable services for auto-start on boot
systemctl enable aitbc-wallet.service
systemctl enable aitbc-coordinator-api.service
systemctl enable aitbc-exchange-api.service
systemctl enable aitbc-blockchain-node.service
systemctl enable aitbc-blockchain-rpc.service
systemctl enable aitbc-gpu.service
systemctl enable aitbc-marketplace.service
systemctl enable aitbc-openclaw.service
systemctl enable aitbc-ai.service
systemctl enable aitbc-learning.service
systemctl enable aitbc-explorer.service
systemctl enable aitbc-web-ui.service
systemctl enable aitbc-agent-coordinator.service
systemctl enable aitbc-agent-registry.service
systemctl enable aitbc-multimodal.service
systemctl enable aitbc-modality-optimization.service
success "Auto-start configured"
}
# Main function
main() {
log "Starting AITBC setup..."
check_root
check_prerequisites
clone_repo
setup_runtime_directories
setup_venvs
install_services
create_health_check
start_services
setup_autostart
success "AITBC setup completed!"
echo ""
echo "Service Information:"
echo " Wallet API: http://localhost:8003/health"
echo " Exchange API: http://localhost:8001/api/health"
echo " Coordinator API: http://localhost:8000/health"
echo ""
echo "Runtime Directories:"
echo " Keystore: /var/lib/aitbc/keystore/"
echo " Data: /var/lib/aitbc/data/"
echo " Logs: /var/lib/aitbc/logs/"
echo " Config: /etc/aitbc/"
echo ""
echo "Management Commands:"
echo " Health check: /opt/aitbc/health-check.sh"
echo " Restart services: systemctl restart aitbc-wallet aitbc-coordinator-api aitbc-exchange-api"
echo " View logs: journalctl -u aitbc-wallet -f"
}
# Run main function
main "$@"

View File

@@ -0,0 +1,100 @@
#!/bin/bash
# Type checking coverage script for AITBC
# Measures and reports type checking coverage
set -euo pipefail
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Main directory
AITBC_ROOT="/opt/aitbc"
cd "$AITBC_ROOT"
# Check if mypy is available
if ! command -v ./venv/bin/mypy &> /dev/null; then
log_error "mypy not found. Please install with: pip install mypy"
exit 1
fi
log_info "Running type checking coverage analysis..."
# Count total Python files
TOTAL_FILES=$(find apps/coordinator-api/src/app -name "*.py" | wc -l)
log_info "Total Python files: $TOTAL_FILES"
# Check core domain files (should pass)
CORE_DOMAIN_FILES=(
"apps/coordinator-api/src/app/domain/job.py"
"apps/coordinator-api/src/app/domain/miner.py"
"apps/coordinator-api/src/app/domain/agent_portfolio.py"
)
CORE_PASSING=0
CORE_TOTAL=${#CORE_DOMAIN_FILES[@]}
for file in "${CORE_DOMAIN_FILES[@]}"; do
if [ -f "$file" ]; then
if ./venv/bin/mypy --ignore-missing-imports "$file" > /dev/null 2>&1; then
((CORE_PASSING++))
log_success "$file"
else
log_error "$file"
fi
fi
done
# Check entire domain directory
DOMAIN_ERRORS=0
if ./venv/bin/mypy --ignore-missing-imports apps/coordinator-api/src/app/domain/ > /dev/null 2>&1; then
log_success "Domain directory: PASSED"
else
DOMAIN_ERRORS=$(./venv/bin/mypy --ignore-missing-imports apps/coordinator-api/src/app/domain/ 2>&1 | grep -c "error:" || echo "0")
log_warning "Domain directory: $DOMAIN_ERRORS errors"
fi
# Calculate coverage percentages
CORE_COVERAGE=$((CORE_PASSING * 100 / CORE_TOTAL))
DOMAIN_COVERAGE=$(( (TOTAL_FILES - DOMAIN_ERRORS) * 100 / TOTAL_FILES ))
# Report results
echo ""
log_info "=== Type Checking Coverage Report ==="
echo "Core Domain Files: $CORE_PASSING/$CORE_TOTAL ($CORE_COVERAGE%)"
echo "Overall Coverage: $((TOTAL_FILES - DOMAIN_ERRORS))/$TOTAL_FILES ($DOMAIN_COVERAGE%)"
echo ""
# Set exit code based on coverage thresholds
THRESHOLD=80
if [ $CORE_COVERAGE -lt $THRESHOLD ]; then
log_error "Core domain coverage below ${THRESHOLD}%: ${CORE_COVERAGE}%"
exit 1
fi
if [ $DOMAIN_COVERAGE -lt $THRESHOLD ]; then
log_warning "Overall coverage below ${THRESHOLD}%: ${DOMAIN_COVERAGE}%"
exit 1
fi
log_success "Type checking coverage meets thresholds (≥${THRESHOLD}%)"