fix: complete system architecture compliance via workflow
✅ Architecture Audit & Rewire Completed - Fixed Python code path references in tests and miner files - Updated SystemD service ReadWritePaths to use system logs - Removed remaining production data and log directories - Updated .gitignore for additional runtime patterns - Created proper system directory structure - Restarted all services for configuration changes ✅ FHS Compliance Achieved - Data: /var/lib/aitbc/data ✅ - Config: /etc/aitbc ✅ - Logs: /var/log/aitbc ✅ - Repository: Clean of runtime files ✅ ✅ Code References Fixed - 0 repository data references ✅ - 0 repository config references ✅ - 0 repository log references ✅ ✅ Services Operational - Marketplace: Active and responding ✅ - Blockchain HTTP: Active and responding ✅ - All services using system paths ✅ 🚀 AITBC system architecture is now fully FHS compliant!
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -327,3 +327,9 @@ logs/
|
|||||||
production/logs/
|
production/logs/
|
||||||
*.log
|
*.log
|
||||||
*.log.*
|
*.log.*
|
||||||
|
production/data/
|
||||||
|
production/logs/
|
||||||
|
dev/cache/logs/
|
||||||
|
dev/test-nodes/*/data/
|
||||||
|
backups/*/config/
|
||||||
|
backups/*/logs/
|
||||||
|
|||||||
212
.windsurf/skills/aitbc-system-architect.md
Normal file
212
.windsurf/skills/aitbc-system-architect.md
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
---
|
||||||
|
name: aitbc-system-architect
|
||||||
|
description: Expert AITBC system architecture management with FHS compliance, system directory structure, and production deployment standards
|
||||||
|
author: AITBC System
|
||||||
|
version: 1.0.0
|
||||||
|
usage: Use this skill for AITBC system architecture tasks, directory management, FHS compliance, and production deployment
|
||||||
|
---
|
||||||
|
|
||||||
|
# AITBC System Architect
|
||||||
|
|
||||||
|
You are an expert AITBC System Architect with deep knowledge of the proper system architecture, Filesystem Hierarchy Standard (FHS) compliance, and production deployment practices for the AITBC blockchain platform.
|
||||||
|
|
||||||
|
## Core Expertise
|
||||||
|
|
||||||
|
### System Architecture
|
||||||
|
- **FHS Compliance**: Expert in Linux Filesystem Hierarchy Standard
|
||||||
|
- **Directory Structure**: `/var/lib/aitbc`, `/etc/aitbc`, `/var/log/aitbc`
|
||||||
|
- **Service Configuration**: SystemD services and production services
|
||||||
|
- **Repository Cleanliness**: Maintaining clean git repositories
|
||||||
|
|
||||||
|
### System Directories
|
||||||
|
- **Data Directory**: `/var/lib/aitbc/data` (all dynamic data)
|
||||||
|
- **Configuration Directory**: `/etc/aitbc` (all system configuration)
|
||||||
|
- **Log Directory**: `/var/log/aitbc` (all system and application logs)
|
||||||
|
- **Repository**: `/opt/aitbc` (clean, code-only)
|
||||||
|
|
||||||
|
### Service Management
|
||||||
|
- **Production Services**: Marketplace, Blockchain, OpenClaw AI
|
||||||
|
- **SystemD Services**: All AITBC services with proper configuration
|
||||||
|
- **Environment Files**: System and production environment management
|
||||||
|
- **Path References**: Ensuring all services use correct system paths
|
||||||
|
|
||||||
|
## Key Capabilities
|
||||||
|
|
||||||
|
### Architecture Management
|
||||||
|
1. **Directory Structure Analysis**: Verify proper FHS compliance
|
||||||
|
2. **Path Migration**: Move runtime files from repository to system locations
|
||||||
|
3. **Service Configuration**: Update services to use system paths
|
||||||
|
4. **Repository Cleanup**: Remove runtime files from git tracking
|
||||||
|
|
||||||
|
### System Compliance
|
||||||
|
1. **FHS Standards**: Ensure compliance with Linux filesystem standards
|
||||||
|
2. **Security**: Proper system permissions and access control
|
||||||
|
3. **Backup Strategy**: Centralized system locations for backup
|
||||||
|
4. **Monitoring**: System integration for logs and metrics
|
||||||
|
|
||||||
|
### Production Deployment
|
||||||
|
1. **Environment Management**: Production vs development configuration
|
||||||
|
2. **Service Dependencies**: Proper service startup and dependencies
|
||||||
|
3. **Log Management**: Centralized logging and rotation
|
||||||
|
4. **Data Integrity**: Proper data storage and access patterns
|
||||||
|
|
||||||
|
## Standard Procedures
|
||||||
|
|
||||||
|
### Directory Structure Verification
|
||||||
|
```bash
|
||||||
|
# Verify system directory structure
|
||||||
|
ls -la /var/lib/aitbc/data/ # Should contain all dynamic data
|
||||||
|
ls -la /etc/aitbc/ # Should contain all configuration
|
||||||
|
ls -la /var/log/aitbc/ # Should contain all logs
|
||||||
|
ls -la /opt/aitbc/ # Should be clean (no runtime files)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Service Path Verification
|
||||||
|
```bash
|
||||||
|
# Check service configurations
|
||||||
|
grep -r "/var/lib/aitbc" /etc/systemd/system/aitbc-*.service
|
||||||
|
grep -r "/etc/aitbc" /etc/systemd/system/aitbc-*.service
|
||||||
|
grep -r "/var/log/aitbc" /etc/systemd/system/aitbc-*.service
|
||||||
|
```
|
||||||
|
|
||||||
|
### Repository Cleanliness Check
|
||||||
|
```bash
|
||||||
|
# Ensure repository is clean
|
||||||
|
git status # Should show no runtime files
|
||||||
|
ls -la /opt/aitbc/data # Should not exist
|
||||||
|
ls -la /opt/aitbc/config # Should not exist
|
||||||
|
ls -la /opt/aitbc/logs # Should not exist
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Tasks
|
||||||
|
|
||||||
|
### 1. System Architecture Audit
|
||||||
|
- Verify FHS compliance
|
||||||
|
- Check directory permissions
|
||||||
|
- Validate service configurations
|
||||||
|
- Ensure repository cleanliness
|
||||||
|
|
||||||
|
### 2. Path Migration
|
||||||
|
- Move data from repository to `/var/lib/aitbc/data`
|
||||||
|
- Move config from repository to `/etc/aitbc`
|
||||||
|
- Move logs from repository to `/var/log/aitbc`
|
||||||
|
- Update all service references
|
||||||
|
|
||||||
|
### 3. Service Configuration
|
||||||
|
- Update SystemD service files
|
||||||
|
- Modify production service configurations
|
||||||
|
- Ensure proper environment file references
|
||||||
|
- Validate ReadWritePaths configuration
|
||||||
|
|
||||||
|
### 4. Repository Management
|
||||||
|
- Add runtime patterns to `.gitignore`
|
||||||
|
- Remove tracked runtime files
|
||||||
|
- Verify clean repository state
|
||||||
|
- Commit architecture changes
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
1. **Service Failures**: Check for incorrect path references
|
||||||
|
2. **Permission Errors**: Verify system directory permissions
|
||||||
|
3. **Git Issues**: Remove runtime files from tracking
|
||||||
|
4. **Configuration Errors**: Validate environment file paths
|
||||||
|
|
||||||
|
### Diagnostic Commands
|
||||||
|
```bash
|
||||||
|
# Service status check
|
||||||
|
systemctl status aitbc-*.service
|
||||||
|
|
||||||
|
# Path verification
|
||||||
|
find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/data\|/opt/aitbc/config\|/opt/aitbc/logs" {} \;
|
||||||
|
|
||||||
|
# System directory verification
|
||||||
|
ls -la /var/lib/aitbc/ /etc/aitbc/ /var/log/aitbc/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
### Architecture Principles
|
||||||
|
1. **Separation of Concerns**: Code, config, data, and logs in separate locations
|
||||||
|
2. **FHS Compliance**: Follow Linux filesystem standards
|
||||||
|
3. **System Integration**: Use standard system tools and practices
|
||||||
|
4. **Security**: Proper permissions and access control
|
||||||
|
|
||||||
|
### Maintenance Procedures
|
||||||
|
1. **Regular Audits**: Periodic verification of system architecture
|
||||||
|
2. **Backup Verification**: Ensure system directories are backed up
|
||||||
|
3. **Log Rotation**: Configure proper log rotation
|
||||||
|
4. **Service Monitoring**: Monitor service health and configuration
|
||||||
|
|
||||||
|
### Development Guidelines
|
||||||
|
1. **Clean Repository**: Keep repository free of runtime files
|
||||||
|
2. **Template Files**: Use `.example` files for configuration templates
|
||||||
|
3. **Environment Isolation**: Separate development and production configs
|
||||||
|
4. **Documentation**: Maintain clear architecture documentation
|
||||||
|
|
||||||
|
## Integration with Other Skills
|
||||||
|
|
||||||
|
### AITBC Operations Skills
|
||||||
|
- **Basic Operations**: Use system architecture knowledge for service management
|
||||||
|
- **AI Operations**: Ensure AI services use proper system paths
|
||||||
|
- **Marketplace Operations**: Verify marketplace data in correct locations
|
||||||
|
|
||||||
|
### OpenClaw Skills
|
||||||
|
- **Agent Communication**: Ensure AI agents use system log paths
|
||||||
|
- **Session Management**: Verify session data in system directories
|
||||||
|
- **Testing Skills**: Use system directories for test data
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
### Example 1: Architecture Audit
|
||||||
|
```
|
||||||
|
User: "Check if our AITBC system follows proper architecture"
|
||||||
|
Response: Perform comprehensive audit of /var/lib/aitbc, /etc/aitbc, /var/log/aitbc structure
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 2: Path Migration
|
||||||
|
```
|
||||||
|
User: "Move runtime data from repository to system location"
|
||||||
|
Response: Execute migration of data, config, and logs to proper system directories
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example 3: Service Configuration
|
||||||
|
```
|
||||||
|
User: "Services are failing to start, check architecture"
|
||||||
|
Response: Verify service configurations reference correct system paths
|
||||||
|
```
|
||||||
|
|
||||||
|
## Performance Metrics
|
||||||
|
|
||||||
|
### Architecture Health Indicators
|
||||||
|
- **FHS Compliance Score**: 100% compliance with Linux standards
|
||||||
|
- **Repository Cleanliness**: 0 runtime files in repository
|
||||||
|
- **Service Path Accuracy**: 100% services use system paths
|
||||||
|
- **Directory Organization**: Proper structure and permissions
|
||||||
|
|
||||||
|
### Monitoring Commands
|
||||||
|
```bash
|
||||||
|
# Architecture health check
|
||||||
|
echo "=== AITBC Architecture Health ==="
|
||||||
|
echo "FHS Compliance: $(check_fhs_compliance)"
|
||||||
|
echo "Repository Clean: $(git status --porcelain | wc -l) files"
|
||||||
|
echo "Service Paths: $(grep -r "/var/lib/aitbc\|/etc/aitbc\|/var/log/aitbc" /etc/systemd/system/aitbc-*.service | wc -l) references"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Continuous Improvement
|
||||||
|
|
||||||
|
### Architecture Evolution
|
||||||
|
- **Standards Compliance**: Keep up with Linux FHS updates
|
||||||
|
- **Service Optimization**: Improve service configuration patterns
|
||||||
|
- **Security Enhancements**: Implement latest security practices
|
||||||
|
- **Performance Tuning**: Optimize system resource usage
|
||||||
|
|
||||||
|
### Documentation Updates
|
||||||
|
- **Architecture Changes**: Document all structural modifications
|
||||||
|
- **Service Updates**: Maintain current service configurations
|
||||||
|
- **Best Practices**: Update guidelines based on experience
|
||||||
|
- **Troubleshooting**: Add new solutions to problem database
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Usage**: Invoke this skill for any AITBC system architecture tasks, FHS compliance verification, system directory management, or production deployment architecture issues.
|
||||||
452
.windsurf/workflows/aitbc-system-architecture-audit.md
Normal file
452
.windsurf/workflows/aitbc-system-architecture-audit.md
Normal file
@@ -0,0 +1,452 @@
|
|||||||
|
---
|
||||||
|
name: aitbc-system-architecture-audit
|
||||||
|
description: Comprehensive AITBC system architecture analysis and path rewire workflow for FHS compliance
|
||||||
|
author: AITBC System Architect
|
||||||
|
version: 1.0.0
|
||||||
|
usage: Use this workflow to analyze AITBC codebase for architecture compliance and automatically rewire incorrect paths
|
||||||
|
---
|
||||||
|
|
||||||
|
# AITBC System Architecture Audit & Rewire Workflow
|
||||||
|
|
||||||
|
This workflow performs comprehensive analysis of the AITBC codebase to ensure proper system architecture compliance and automatically rewire any incorrect paths to follow FHS standards.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
### System Requirements
|
||||||
|
- AITBC system deployed with proper directory structure
|
||||||
|
- SystemD services running
|
||||||
|
- Git repository clean of runtime files
|
||||||
|
- Administrative access to system directories
|
||||||
|
|
||||||
|
### Required Directories
|
||||||
|
- `/var/lib/aitbc/data` - Dynamic data storage
|
||||||
|
- `/etc/aitbc` - System configuration
|
||||||
|
- `/var/log/aitbc` - System and application logs
|
||||||
|
- `/opt/aitbc` - Clean repository (code only)
|
||||||
|
|
||||||
|
## Workflow Phases
|
||||||
|
|
||||||
|
### Phase 1: Architecture Analysis
|
||||||
|
**Objective**: Comprehensive analysis of current system architecture compliance
|
||||||
|
|
||||||
|
#### 1.1 Directory Structure Analysis
|
||||||
|
```bash
|
||||||
|
# Analyze current directory structure
|
||||||
|
echo "=== AITBC System Architecture Analysis ==="
|
||||||
|
echo ""
|
||||||
|
echo "=== 1. DIRECTORY STRUCTURE ANALYSIS ==="
|
||||||
|
|
||||||
|
# Check repository cleanliness
|
||||||
|
echo "Repository Analysis:"
|
||||||
|
ls -la /opt/aitbc/ | grep -E "(data|config|logs)" || echo "✅ Repository clean"
|
||||||
|
|
||||||
|
# Check system directories
|
||||||
|
echo "System Directory Analysis:"
|
||||||
|
echo "Data directory: $(ls -la /var/lib/aitbc/data/ 2>/dev/null | wc -l) items"
|
||||||
|
echo "Config directory: $(ls -la /etc/aitbc/ 2>/dev/null | wc -l) items"
|
||||||
|
echo "Log directory: $(ls -la /var/log/aitbc/ 2>/dev/null | wc -l) items"
|
||||||
|
|
||||||
|
# Check for incorrect directory usage
|
||||||
|
echo "Incorrect Directory Usage:"
|
||||||
|
find /opt/aitbc -name "data" -o -name "config" -o -name "logs" 2>/dev/null || echo "✅ No incorrect directories found"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 1.2 Code Path Analysis
|
||||||
|
```bash
|
||||||
|
# Analyze code for incorrect path references
|
||||||
|
echo "=== 2. CODE PATH ANALYSIS ==="
|
||||||
|
|
||||||
|
# Find repository data references
|
||||||
|
echo "Repository Data References:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/data" {} \; 2>/dev/null || echo "✅ No repository data references"
|
||||||
|
|
||||||
|
# Find repository config references
|
||||||
|
echo "Repository Config References:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/config" {} \; 2>/dev/null || echo "✅ No repository config references"
|
||||||
|
|
||||||
|
# Find repository log references
|
||||||
|
echo "Repository Log References:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/logs" {} \; 2>/dev/null || echo "✅ No repository log references"
|
||||||
|
|
||||||
|
# Find production data references
|
||||||
|
echo "Production Data References:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/production/data" {} \; 2>/dev/null || echo "✅ No production data references"
|
||||||
|
|
||||||
|
# Find production config references
|
||||||
|
echo "Production Config References:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/production/.env" {} \; 2>/dev/null || echo "✅ No production config references"
|
||||||
|
|
||||||
|
# Find production log references
|
||||||
|
echo "Production Log References:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/production/logs" {} \; 2>/dev/null || echo "✅ No production log references"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 1.3 SystemD Service Analysis
|
||||||
|
```bash
|
||||||
|
# Analyze SystemD service configurations
|
||||||
|
echo "=== 3. SYSTEMD SERVICE ANALYSIS ==="
|
||||||
|
|
||||||
|
# Check service file paths
|
||||||
|
echo "Service File Analysis:"
|
||||||
|
grep -r "EnvironmentFile" /etc/systemd/system/aitbc-*.service 2>/dev/null || echo "✅ No EnvironmentFile issues"
|
||||||
|
|
||||||
|
# Check ReadWritePaths
|
||||||
|
echo "ReadWritePaths Analysis:"
|
||||||
|
grep -r "ReadWritePaths" /etc/systemd/system/aitbc-*.service 2>/dev/null || echo "✅ No ReadWritePaths issues"
|
||||||
|
|
||||||
|
# Check for incorrect paths in services
|
||||||
|
echo "Incorrect Service Paths:"
|
||||||
|
grep -r "/opt/aitbc/data\|/opt/aitbc/config\|/opt/aitbc/logs" /etc/systemd/system/aitbc-*.service 2>/dev/null || echo "✅ No incorrect service paths"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 2: Architecture Compliance Check
|
||||||
|
**Objective**: Verify FHS compliance and identify violations
|
||||||
|
|
||||||
|
#### 2.1 FHS Compliance Verification
|
||||||
|
```bash
|
||||||
|
# Verify FHS compliance
|
||||||
|
echo "=== 4. FHS COMPLIANCE VERIFICATION ==="
|
||||||
|
|
||||||
|
# Check data in /var/lib
|
||||||
|
echo "Data Location Compliance:"
|
||||||
|
if [ -d "/var/lib/aitbc/data" ]; then
|
||||||
|
echo "✅ Data in /var/lib/aitbc/data"
|
||||||
|
else
|
||||||
|
echo "❌ Data not in /var/lib/aitbc/data"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check config in /etc
|
||||||
|
echo "Config Location Compliance:"
|
||||||
|
if [ -d "/etc/aitbc" ]; then
|
||||||
|
echo "✅ Config in /etc/aitbc"
|
||||||
|
else
|
||||||
|
echo "❌ Config not in /etc/aitbc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check logs in /var/log
|
||||||
|
echo "Log Location Compliance:"
|
||||||
|
if [ -d "/var/log/aitbc" ]; then
|
||||||
|
echo "✅ Logs in /var/log/aitbc"
|
||||||
|
else
|
||||||
|
echo "❌ Logs not in /var/log/aitbc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check repository cleanliness
|
||||||
|
echo "Repository Cleanliness:"
|
||||||
|
if [ ! -d "/opt/aitbc/data" ] && [ ! -d "/opt/aitbc/config" ] && [ ! -d "/opt/aitbc/logs" ]; then
|
||||||
|
echo "✅ Repository clean"
|
||||||
|
else
|
||||||
|
echo "❌ Repository contains runtime directories"
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2.2 Git Repository Analysis
|
||||||
|
```bash
|
||||||
|
# Analyze git repository for runtime files
|
||||||
|
echo "=== 5. GIT REPOSITORY ANALYSIS ==="
|
||||||
|
|
||||||
|
# Check git status
|
||||||
|
echo "Git Status:"
|
||||||
|
git status --porcelain | head -5
|
||||||
|
|
||||||
|
# Check .gitignore
|
||||||
|
echo "GitIgnore Analysis:"
|
||||||
|
if grep -q "data/\|config/\|logs/\|*.log\|*.db" .gitignore; then
|
||||||
|
echo "✅ GitIgnore properly configured"
|
||||||
|
else
|
||||||
|
echo "❌ GitIgnore missing runtime patterns"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for tracked runtime files
|
||||||
|
echo "Tracked Runtime Files:"
|
||||||
|
git ls-files | grep -E "(data/|config/|logs/|\.log|\.db)" || echo "✅ No tracked runtime files"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 3: Path Rewire Operations
|
||||||
|
**Objective**: Automatically rewire incorrect paths to system locations
|
||||||
|
|
||||||
|
#### 3.1 Python Code Path Rewire
|
||||||
|
```bash
|
||||||
|
# Rewire Python code paths
|
||||||
|
echo "=== 6. PYTHON CODE PATH REWIRE ==="
|
||||||
|
|
||||||
|
# Rewire data paths
|
||||||
|
echo "Rewiring Data Paths:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec sed -i 's|/opt/aitbc/data|/var/lib/aitbc/data|g' {} \;
|
||||||
|
find /opt/aitbc -name "*.py" -exec sed -i 's|/opt/aitbc/production/data|/var/lib/aitbc/data|g' {} \;
|
||||||
|
echo "✅ Data paths rewired"
|
||||||
|
|
||||||
|
# Rewire config paths
|
||||||
|
echo "Rewiring Config Paths:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec sed -i 's|/opt/aitbc/config|/etc/aitbc|g' {} \;
|
||||||
|
find /opt/aitbc -name "*.py" -exec sed -i 's|/opt/aitbc/production/.env|/etc/aitbc/production.env|g' {} \;
|
||||||
|
echo "✅ Config paths rewired"
|
||||||
|
|
||||||
|
# Rewire log paths
|
||||||
|
echo "Rewiring Log Paths:"
|
||||||
|
find /opt/aitbc -name "*.py" -exec sed -i 's|/opt/aitbc/logs|/var/log/aitbc|g' {} \;
|
||||||
|
find /opt/aitbc -name "*.py" -exec sed -i 's|/opt/aitbc/production/logs|/var/log/aitbc/production|g' {} \;
|
||||||
|
echo "✅ Log paths rewired"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3.2 SystemD Service Path Rewire
|
||||||
|
```bash
|
||||||
|
# Rewire SystemD service paths
|
||||||
|
echo "=== 7. SYSTEMD SERVICE PATH REWIRE ==="
|
||||||
|
|
||||||
|
# Rewire EnvironmentFile paths
|
||||||
|
echo "Rewiring EnvironmentFile Paths:"
|
||||||
|
find /etc/systemd/system/aitbc-*.service -exec sed -i 's|EnvironmentFile=/opt/aitbc/.env|EnvironmentFile=/etc/aitbc/.env|g' {} \;
|
||||||
|
find /etc/systemd/system/aitbc-*.service -exec sed -i 's|EnvironmentFile=/opt/aitbc/production/.env|EnvironmentFile=/etc/aitbc/production.env|g' {} \;
|
||||||
|
echo "✅ EnvironmentFile paths rewired"
|
||||||
|
|
||||||
|
# Rewire ReadWritePaths
|
||||||
|
echo "Rewiring ReadWritePaths:"
|
||||||
|
find /etc/systemd/system/aitbc-*.service -exec sed -i 's|/opt/aitbc/production/data|/var/lib/aitbc/data|g' {} \;
|
||||||
|
find /etc/systemd/system/aitbc-*.service -exec sed -i 's|/opt/aitbc/production/logs|/var/log/aitbc/production|g' {} \;
|
||||||
|
echo "✅ ReadWritePaths rewired"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3.3 Drop-in Configuration Rewire
|
||||||
|
```bash
|
||||||
|
# Rewire drop-in configuration files
|
||||||
|
echo "=== 8. DROP-IN CONFIGURATION REWIRE ==="
|
||||||
|
|
||||||
|
# Find and rewire drop-in files
|
||||||
|
find /etc/systemd/system/aitbc-*.service.d/ -name "*.conf" -exec sed -i 's|EnvironmentFile=/opt/aitbc/.env|EnvironmentFile=/etc/aitbc/.env|g' {} \;
|
||||||
|
find /etc/systemd/system/aitbc-*.service.d/ -name "*.conf" -exec sed -i 's|/opt/aitbc/production/.env|EnvironmentFile=/etc/aitbc/production.env|g' {} \;
|
||||||
|
echo "✅ Drop-in configurations rewired"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 4: System Directory Creation
|
||||||
|
**Objective**: Ensure proper system directory structure exists
|
||||||
|
|
||||||
|
#### 4.1 Create System Directories
|
||||||
|
```bash
|
||||||
|
# Create system directories
|
||||||
|
echo "=== 9. SYSTEM DIRECTORY CREATION ==="
|
||||||
|
|
||||||
|
# Create data directories
|
||||||
|
echo "Creating Data Directories:"
|
||||||
|
mkdir -p /var/lib/aitbc/data/blockchain
|
||||||
|
mkdir -p /var/lib/aitbc/data/marketplace
|
||||||
|
mkdir -p /var/lib/aitbc/data/openclaw
|
||||||
|
mkdir -p /var/lib/aitbc/data/coordinator
|
||||||
|
mkdir -p /var/lib/aitbc/data/exchange
|
||||||
|
mkdir -p /var/lib/aitbc/data/registry
|
||||||
|
echo "✅ Data directories created"
|
||||||
|
|
||||||
|
# Create log directories
|
||||||
|
echo "Creating Log Directories:"
|
||||||
|
mkdir -p /var/log/aitbc/production/blockchain
|
||||||
|
mkdir -p /var/log/aitbc/production/marketplace
|
||||||
|
mkdir -p /var/log/aitbc/production/openclaw
|
||||||
|
mkdir -p /var/log/aitbc/production/services
|
||||||
|
mkdir -p /var/log/aitbc/production/errors
|
||||||
|
mkdir -p /var/log/aitbc/repository-logs
|
||||||
|
echo "✅ Log directories created"
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
echo "Setting Permissions:"
|
||||||
|
chmod 755 /var/lib/aitbc/data
|
||||||
|
chmod 755 /var/lib/aitbc/data/*
|
||||||
|
chmod 755 /var/log/aitbc
|
||||||
|
chmod 755 /var/log/aitbc/*
|
||||||
|
echo "✅ Permissions set"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 5: Repository Cleanup
|
||||||
|
**Objective**: Clean repository of runtime files
|
||||||
|
|
||||||
|
#### 5.1 Remove Runtime Directories
|
||||||
|
```bash
|
||||||
|
# Remove runtime directories from repository
|
||||||
|
echo "=== 10. REPOSITORY CLEANUP ==="
|
||||||
|
|
||||||
|
# Remove data directories
|
||||||
|
echo "Removing Runtime Directories:"
|
||||||
|
rm -rf /opt/aitbc/data 2>/dev/null || echo "No data directory to remove"
|
||||||
|
rm -rf /opt/aitbc/config 2>/dev/null || echo "No config directory to remove"
|
||||||
|
rm -rf /opt/aitbc/logs 2>/dev/null || echo "No logs directory to remove"
|
||||||
|
rm -rf /opt/aitbc/production/data 2>/dev/null || echo "No production data directory to remove"
|
||||||
|
rm -rf /opt/aitbc/production/logs 2>/dev/null || echo "No production logs directory to remove"
|
||||||
|
echo "✅ Runtime directories removed"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5.2 Update GitIgnore
|
||||||
|
```bash
|
||||||
|
# Update .gitignore
|
||||||
|
echo "Updating GitIgnore:"
|
||||||
|
echo "data/" >> .gitignore
|
||||||
|
echo "config/" >> .gitignore
|
||||||
|
echo "logs/" >> .gitignore
|
||||||
|
echo "production/data/" >> .gitignore
|
||||||
|
echo "production/logs/" >> .gitignore
|
||||||
|
echo "*.log" >> .gitignore
|
||||||
|
echo "*.log.*" >> .gitignore
|
||||||
|
echo "*.db" >> .gitignore
|
||||||
|
echo "*.db-wal" >> .gitignore
|
||||||
|
echo "*.db-shm" >> .gitignore
|
||||||
|
echo "!*.example" >> .gitignore
|
||||||
|
echo "✅ GitIgnore updated"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5.3 Remove Tracked Files
|
||||||
|
```bash
|
||||||
|
# Remove tracked runtime files
|
||||||
|
echo "Removing Tracked Runtime Files:"
|
||||||
|
git rm -r --cached data/ 2>/dev/null || echo "No data directory tracked"
|
||||||
|
git rm -r --cached config/ 2>/dev/null || echo "No config directory tracked"
|
||||||
|
git rm -r --cached logs/ 2>/dev/null || echo "No logs directory tracked"
|
||||||
|
git rm -r --cached production/data/ 2>/dev/null || echo "No production data directory tracked"
|
||||||
|
git rm -r --cached production/logs/ 2>/dev/null || echo "No production logs directory tracked"
|
||||||
|
echo "✅ Tracked runtime files removed"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 6: Service Restart and Verification
|
||||||
|
**Objective**: Restart services and verify proper operation
|
||||||
|
|
||||||
|
#### 6.1 SystemD Reload
|
||||||
|
```bash
|
||||||
|
# Reload SystemD
|
||||||
|
echo "=== 11. SYSTEMD RELOAD ==="
|
||||||
|
systemctl daemon-reload
|
||||||
|
echo "✅ SystemD reloaded"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 6.2 Service Restart
|
||||||
|
```bash
|
||||||
|
# Restart AITBC services
|
||||||
|
echo "=== 12. SERVICE RESTART ==="
|
||||||
|
services=("aitbc-marketplace.service" "aitbc-mining-blockchain.service" "aitbc-openclaw-ai.service" "aitbc-blockchain-node.service" "aitbc-blockchain-rpc.service")
|
||||||
|
|
||||||
|
for service in "${services[@]}"; do
|
||||||
|
echo "Restarting $service..."
|
||||||
|
systemctl restart "$service" 2>/dev/null || echo "Service $service not found"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "✅ Services restarted"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 6.3 Service Verification
|
||||||
|
```bash
|
||||||
|
# Verify service status
|
||||||
|
echo "=== 13. SERVICE VERIFICATION ==="
|
||||||
|
|
||||||
|
# Check service status
|
||||||
|
echo "Service Status:"
|
||||||
|
for service in "${services[@]}"; do
|
||||||
|
status=$(systemctl is-active "$service" 2>/dev/null || echo "not-found")
|
||||||
|
echo "$service: $status"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Test marketplace service
|
||||||
|
echo "Marketplace Test:"
|
||||||
|
curl -s http://localhost:8002/health 2>/dev/null | jq '.status' 2>/dev/null || echo "Marketplace not responding"
|
||||||
|
|
||||||
|
# Test blockchain service
|
||||||
|
echo "Blockchain Test:"
|
||||||
|
curl -s http://localhost:8005/health 2>/dev/null | jq '.status' 2>/dev/null || echo "Blockchain HTTP not responding"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Phase 7: Final Verification
|
||||||
|
**Objective**: Comprehensive verification of architecture compliance
|
||||||
|
|
||||||
|
#### 7.1 Architecture Compliance Check
|
||||||
|
```bash
|
||||||
|
# Final architecture compliance check
|
||||||
|
echo "=== 14. FINAL ARCHITECTURE COMPLIANCE CHECK ==="
|
||||||
|
|
||||||
|
# Check system directories
|
||||||
|
echo "System Directory Check:"
|
||||||
|
echo "Data: $(test -d /var/lib/aitbc/data && echo "✅" || echo "❌")"
|
||||||
|
echo "Config: $(test -d /etc/aitbc && echo "✅" || echo "❌")"
|
||||||
|
echo "Logs: $(test -d /var/log/aitbc && echo "✅" || echo "❌")"
|
||||||
|
|
||||||
|
# Check repository cleanliness
|
||||||
|
echo "Repository Cleanliness:"
|
||||||
|
echo "No data dir: $(test ! -d /opt/aitbc/data && echo "✅" || echo "❌")"
|
||||||
|
echo "No config dir: $(test ! -d /opt/aitbc/config && echo "✅" || echo "❌")"
|
||||||
|
echo "No logs dir: $(test ! -d /opt/aitbc/logs && echo "✅" || echo "❌")"
|
||||||
|
|
||||||
|
# Check path references
|
||||||
|
echo "Path References:"
|
||||||
|
echo "No repo data refs: $(find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/data" {} \; 2>/dev/null | wc -l)"
|
||||||
|
echo "No repo config refs: $(find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/config" {} \; 2>/dev/null | wc -l)"
|
||||||
|
echo "No repo log refs: $(find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/logs" {} \; 2>/dev/null | wc -l)"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 7.2 Generate Report
|
||||||
|
```bash
|
||||||
|
# Generate architecture compliance report
|
||||||
|
echo "=== 15. ARCHITECTURE COMPLIANCE REPORT ==="
|
||||||
|
echo "Generated on: $(date)"
|
||||||
|
echo ""
|
||||||
|
echo "✅ COMPLETED TASKS:"
|
||||||
|
echo " • Directory structure analysis"
|
||||||
|
echo " • Code path analysis"
|
||||||
|
echo " • SystemD service analysis"
|
||||||
|
echo " • FHS compliance verification"
|
||||||
|
echo " • Git repository analysis"
|
||||||
|
echo " • Python code path rewire"
|
||||||
|
echo " • SystemD service path rewire"
|
||||||
|
echo " • System directory creation"
|
||||||
|
echo " • Repository cleanup"
|
||||||
|
echo " • Service restart and verification"
|
||||||
|
echo " • Final compliance check"
|
||||||
|
echo ""
|
||||||
|
echo "🎯 AITBC SYSTEM ARCHITECTURE IS NOW FHS COMPLIANT!"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Success Metrics
|
||||||
|
|
||||||
|
### Architecture Compliance
|
||||||
|
- **FHS Compliance**: 100% compliance with Linux standards
|
||||||
|
- **Repository Cleanliness**: 0 runtime files in repository
|
||||||
|
- **Path Accuracy**: 100% services use system paths
|
||||||
|
- **Service Health**: All services operational
|
||||||
|
|
||||||
|
### System Integration
|
||||||
|
- **SystemD Integration**: All services properly configured
|
||||||
|
- **Log Management**: Centralized logging system
|
||||||
|
- **Data Storage**: Proper data directory structure
|
||||||
|
- **Configuration**: System-wide configuration management
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Common Issues
|
||||||
|
1. **Service Failures**: Check for incorrect path references
|
||||||
|
2. **Permission Errors**: Verify system directory permissions
|
||||||
|
3. **Path Conflicts**: Ensure no hardcoded repository paths
|
||||||
|
4. **Git Issues**: Remove runtime files from tracking
|
||||||
|
|
||||||
|
### Recovery Commands
|
||||||
|
```bash
|
||||||
|
# Service recovery
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl restart aitbc-*.service
|
||||||
|
|
||||||
|
# Path verification
|
||||||
|
find /opt/aitbc -name "*.py" -exec grep -l "/opt/aitbc/data\|/opt/aitbc/config\|/opt/aitbc/logs" {} \;
|
||||||
|
|
||||||
|
# Directory verification
|
||||||
|
ls -la /var/lib/aitbc/ /etc/aitbc/ /var/log/aitbc/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage Instructions
|
||||||
|
|
||||||
|
### Running the Workflow
|
||||||
|
1. Execute the workflow phases in sequence
|
||||||
|
2. Monitor each phase for errors
|
||||||
|
3. Verify service operation after completion
|
||||||
|
4. Review final compliance report
|
||||||
|
|
||||||
|
### Customization
|
||||||
|
- **Phase Selection**: Run specific phases as needed
|
||||||
|
- **Service Selection**: Modify service list for specific requirements
|
||||||
|
- **Path Customization**: Adapt paths for different environments
|
||||||
|
- **Reporting**: Customize report format and content
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**This workflow ensures complete AITBC system architecture compliance with automatic path rewire and comprehensive verification.**
|
||||||
@@ -22,7 +22,7 @@ MAX_RETRIES = 10
|
|||||||
RETRY_DELAY = 30
|
RETRY_DELAY = 30
|
||||||
|
|
||||||
# Setup logging with explicit configuration
|
# Setup logging with explicit configuration
|
||||||
LOG_PATH = "/opt/aitbc/logs/production_miner.log"
|
LOG_PATH = "/var/log/aitbc/production_miner.log"
|
||||||
os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
|
os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
|
||||||
|
|
||||||
class FlushHandler(logging.StreamHandler):
|
class FlushHandler(logging.StreamHandler):
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ MAX_RETRIES = 10
|
|||||||
RETRY_DELAY = 30
|
RETRY_DELAY = 30
|
||||||
|
|
||||||
# Setup logging with explicit configuration
|
# Setup logging with explicit configuration
|
||||||
LOG_PATH = "/opt/aitbc/logs/host_gpu_miner.log"
|
LOG_PATH = "/var/log/aitbc/host_gpu_miner.log"
|
||||||
os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
|
os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
|
||||||
|
|
||||||
class FlushHandler(logging.StreamHandler):
|
class FlushHandler(logging.StreamHandler):
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ MAX_RETRIES = 10
|
|||||||
RETRY_DELAY = 30
|
RETRY_DELAY = 30
|
||||||
|
|
||||||
# Setup logging with explicit configuration
|
# Setup logging with explicit configuration
|
||||||
LOG_PATH = "/opt/aitbc/logs/host_gpu_miner.log"
|
LOG_PATH = "/var/log/aitbc/host_gpu_miner.log"
|
||||||
os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
|
os.makedirs(os.path.dirname(LOG_PATH), exist_ok=True)
|
||||||
|
|
||||||
class FlushHandler(logging.StreamHandler):
|
class FlushHandler(logging.StreamHandler):
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ LOGGING_CONFIG = {
|
|||||||
'handlers': {
|
'handlers': {
|
||||||
'file': {
|
'file': {
|
||||||
'class': 'logging.handlers.RotatingFileHandler',
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
'filename': '/opt/aitbc/production/logs/services/aitbc.log',
|
'filename': '/var/log/aitbc/production/services/aitbc.log',
|
||||||
'maxBytes': 10485760, # 10MB
|
'maxBytes': 10485760, # 10MB
|
||||||
'backupCount': 5,
|
'backupCount': 5,
|
||||||
'formatter': 'production'
|
'formatter': 'production'
|
||||||
|
|||||||
@@ -987,7 +987,7 @@ class TestMeshNetworkTransition:
|
|||||||
|
|
||||||
def test_configuration_files(self):
|
def test_configuration_files(self):
|
||||||
"""Test that all configuration files are created"""
|
"""Test that all configuration files are created"""
|
||||||
config_dir = '/opt/aitbc/config'
|
config_dir = '/etc/aitbc'
|
||||||
configs = [
|
configs = [
|
||||||
'consensus_test.json',
|
'consensus_test.json',
|
||||||
'network_test.json',
|
'network_test.json',
|
||||||
|
|||||||
@@ -603,7 +603,7 @@ class TestConfigurationIntegration:
|
|||||||
"""Test that configuration files are consistent across phases"""
|
"""Test that configuration files are consistent across phases"""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
config_dir = "/opt/aitbc/config"
|
config_dir = "/etc/aitbc"
|
||||||
configs = {
|
configs = {
|
||||||
"consensus_test.json": {"min_validators": 3, "block_time": 30},
|
"consensus_test.json": {"min_validators": 3, "block_time": 30},
|
||||||
"network_test.json": {"max_peers": 50, "discovery_interval": 30},
|
"network_test.json": {"max_peers": 50, "discovery_interval": 30},
|
||||||
|
|||||||
Reference in New Issue
Block a user