Warning, /swf-testbed/CLAUDE-toplevel.md is written in an unsupported language. File is not indexed.
0001 # CLAUDE.md
0002
0003 This file provides guidance to Claude Code (claude.ai/code) when working with the SWF (Streaming Workflow) testbed ecosystem.
0004
0005 ## SWF Testbed Ecosystem Overview
0006
0007 This directory contains the coordinated multi-repository system for the **ePIC streaming workflow testbed** - a distributed scientific computing system for high-energy physics data processing.
0008
0009 ### Repository Structure
0010 ```
0011 github/
0012 ├── swf-testbed/ # Infrastructure, CLI, and orchestration (REQUIRED)
0013 ├── swf-monitor/ # Django web application for monitoring (REQUIRED)
0014 ├── swf-common-lib/ # Shared utilities library (REQUIRED)
0015 ├── swf-data-agent/ # Data management agent (optional)
0016 ├── swf-processing-agent/ # Processing workflow agent (optional)
0017 └── swf-fastmon-agent/ # Fast monitoring agent (optional)
0018 ```
0019
0020 **Critical**: The three core repositories (swf-testbed, swf-monitor, swf-common-lib) must exist as siblings in the same parent directory. Additional agent repositories are optional and will be added as the testbed expands.
0021
0022 ## Multi-Repository Development Workflow
0023
0024 ### Infrastructure Branching Strategy
0025 - **Always use infrastructure branches**: `infra/baseline-v1`, `infra/baseline-v2`, etc.
0026 - **Create coordinated branches** with the same name across all affected repositories
0027 - **Document changes** through descriptive commit messages, not branch names
0028 - **Never push directly to main** - always use branches and pull requests
0029
0030 ### Current Infrastructure Versions
0031 **CURRENT STATUS**: All core repositories are on coordinated `infra/baseline-v3` branches with:
0032 - Virtual environment documentation updates (CRITICAL warnings added)
0033 - Top-level CLAUDE.md moved to swf-testbed/CLAUDE-toplevel.md with symlink
0034 - Directory verification guidance added
0035
0036 Check for existing infrastructure branches across core repositories:
0037 ```bash
0038 # Check core repos for current infrastructure baseline
0039 for repo in swf-testbed swf-monitor swf-common-lib; do
0040 echo "=== $repo ==="
0041 cd $repo && git branch -a | grep infra && cd ..
0042 done
0043 ```
0044
0045 ### Coordination Commands
0046 ```bash
0047 # Create coordinated infrastructure branch across core repos
0048 for repo in swf-testbed swf-monitor swf-common-lib; do
0049 cd $repo && git checkout -b infra/baseline-vN && cd ..
0050 done
0051
0052 # Run comprehensive tests across all repositories
0053 cd swf-testbed && ./run_all_tests.sh
0054 ```
0055
0056 ## Quick Start Commands
0057
0058 ### System Initialization
0059 ```bash
0060 cd $SWF_PARENT_DIR/swf-testbed
0061 source .venv/bin/activate
0062 pip install -e $SWF_PARENT_DIR/swf-common-lib $SWF_PARENT_DIR/swf-monitor .
0063 # CRITICAL: Set up Django environment
0064 cp $SWF_PARENT_DIR/swf-monitor/.env.example $SWF_PARENT_DIR/swf-monitor/.env
0065 # Edit .env to set DB_PASSWORD='your_db_password' and SECRET_KEY
0066 cd $SWF_PARENT_DIR/swf-monitor/src && python manage.py migrate
0067 cd $SWF_PARENT_DIR/swf-testbed && swf-testbed init
0068 ```
0069
0070 ### Infrastructure Services
0071 ```bash
0072 # Start with Docker (recommended)
0073 cd $SWF_PARENT_DIR/swf-testbed && swf-testbed start
0074
0075 # Or start locally (requires PostgreSQL/ActiveMQ installed)
0076 cd $SWF_PARENT_DIR/swf-testbed && swf-testbed start-local
0077 ```
0078
0079 ### Testing
0080 ```bash
0081 # Test entire ecosystem
0082 cd $SWF_PARENT_DIR/swf-testbed && ./run_all_tests.sh
0083
0084 # Test individual components
0085 cd $SWF_PARENT_DIR/swf-monitor && ./run_tests.sh
0086 cd $SWF_PARENT_DIR/swf-common-lib && ./run_tests.sh
0087 ```
0088
0089 ## Repository-Specific Guidance
0090
0091 Each repository contains its own CLAUDE.md with detailed, repository-specific guidance:
0092
0093 - **swf-testbed/CLAUDE.md**: CLI commands, process management, Docker orchestration
0094 - **swf-monitor/CLAUDE.md**: Django development, database migrations, ActiveMQ integration
0095 - **swf-common-lib/CLAUDE.md**: Shared utilities, logging infrastructure, packaging
0096
0097 **IMPORTANT**: When working with this ecosystem, Claude Code should automatically read all repository-specific CLAUDE.md files from the three core repositories (swf-testbed, swf-monitor, swf-common-lib) to understand the complete system context and available commands.
0098
0099 **CRITICAL**: Always verify current working directory with `pwd` before any operations, especially git commands. Never assume location - always check explicitly to prevent errors in multi-repository workflows.
0100
0101 ## System Architecture
0102
0103 ### Distributed Agent System
0104 - **Loosely coupled agents** communicating via ActiveMQ messaging
0105 - **Process management** via supervisord for cross-platform compatibility
0106 - **Web monitoring** via Django application with REST API
0107 - **Shared utilities** via common library for logging and utilities
0108
0109 ### Infrastructure Services
0110 - **PostgreSQL**: Database for monitoring data and metadata
0111 - **ActiveMQ**: Message broker for agent communication
0112 - **Docker Compose**: Development infrastructure services
0113 - **supervisord**: Cross-platform process management
0114
0115 ### External Dependencies
0116 - **PanDA**: Distributed workload management system
0117 - **Rucio**: Distributed data management system
0118 - Scientific computing focus for ePIC experiment data processing
0119
0120 ## Development Best Practices
0121
0122 ### Cross-Repository Changes
0123 1. **Plan infrastructure phase**: Identify all repositories that need changes
0124 2. **Create coordinated branches**: Same `infra/baseline-vN` across affected repos
0125 3. **Work systematically**: Make changes across repositories as needed
0126 4. **Test integration**: Run `./run_all_tests.sh` before merging
0127 5. **Coordinate merges**: Merge pull requests simultaneously across repositories
0128
0129 ### Environment Requirements
0130 - **Python 3.9+** across all repositories
0131 - **Docker Desktop** for development infrastructure
0132 - **Git** with coordinated branch management
0133 - **PostgreSQL + ActiveMQ** (via Docker or local installation)
0134
0135 ### Testing Strategy
0136 - **Repository isolation**: Each repo has independent test suite
0137 - **Integration testing**: Cross-repository test execution via `run_all_tests.sh`
0138 - **Mock external dependencies**: PostgreSQL, ActiveMQ, HTTP APIs
0139 - **Platform compatibility**: Tests run on macOS, Linux, Windows
0140
0141 ## Security and Configuration
0142
0143 ### Secrets Management
0144 - **Environment variables** via `.env` files (never committed)
0145 - **Database credentials** isolated per environment
0146 - **API keys and tokens** via secure environment configuration
0147 - **Production deployment** requires additional security hardening
0148
0149 ### Configuration Files
0150 - `.env.example` files provide templates for environment setup
0151 - `docker-compose.yml` for development infrastructure
0152 - `supervisord.conf` for process management configuration
0153 - `pyproject.toml` for Python packaging and dependencies
0154
0155 ## Troubleshooting
0156
0157 ### Common Issues
0158 - **Virtual Environment Persistence**: The shell environment, including the activated virtual environment, does **not** persist between `run_shell_command` calls. You **MUST** chain environment setup and the command that requires it in a single call.
0159 - **Correct**: `cd swf-testbed && source ./install.sh && cd ../swf-monitor && python3 src/manage.py migrate`
0160 - **Incorrect**: Running `source ./install.sh` in one call and `python3 src/manage.py migrate` in another.
0161 - **Core repository structure**: Ensure swf-testbed, swf-monitor, and swf-common-lib are siblings
0162 - **Environment variables**: Check SWF_HOME is set correctly (auto-configured by CLI)
0163 - **Database connections**: Verify PostgreSQL is running and accessible
0164 - **ActiveMQ connectivity**: Check message broker is running on expected ports
0165
0166 ### Diagnostic Commands
0167 ```bash
0168 # Check system status
0169 cd swf-testbed && swf-testbed status # or status-local
0170
0171 # Verify core repository structure
0172 ls -la swf-testbed swf-monitor swf-common-lib
0173
0174 # Check branch coordination across core repos
0175 for repo in swf-testbed swf-monitor swf-common-lib; do echo "=== $repo ===" && cd $repo && git branch && cd ..; done
0176 ```
0177
0178 This ecosystem requires coordinated development across the three core repositories with careful attention to infrastructure branching and testing integration.