|
| 1 | +# FUSION Project Context for AI Assistants |
| 2 | + |
| 3 | +This document provides context for AI assistants (like Claude) working with the FUSION codebase. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +FUSION (Flexible Unified System for Intelligent Optical Networking) is an open-source simulation framework for Software Defined Elastic Optical Networks (SD-EONs) with extensions for AI/ML integration, particularly reinforcement learning for network optimization and survivability. |
| 8 | + |
| 9 | +## Key Architectural Concepts |
| 10 | + |
| 11 | +### Core Simulation Components |
| 12 | +- **Discrete Event Simulation**: Event-driven network request processing |
| 13 | +- **RSA (Routing and Spectrum Assignment)**: The fundamental resource allocation problem |
| 14 | +- **Network Topology**: Graph-based representation using NetworkX |
| 15 | +- **Spectrum Management**: Flexible grid optical spectrum allocation |
| 16 | +- **Traffic Generation**: Poisson arrival process with configurable parameters |
| 17 | + |
| 18 | +### Reinforcement Learning Integration |
| 19 | +- **Offline RL**: Training from heuristic behavior logs (BC, IQL, CQL) |
| 20 | +- **Online RL**: Integration with Stable-Baselines3 (PPO, A2C, DQN) |
| 21 | +- **Action Masking**: Safety mechanism to prevent invalid actions |
| 22 | +- **Policy Evaluation**: Baseline comparison and metrics collection |
| 23 | + |
| 24 | +### Survivability Features |
| 25 | +- **Failure Types**: Link (F1), Node (F2), SRLG (F3), Geographic (F4) |
| 26 | +- **Protection Mechanisms**: 1+1 disjoint path protection |
| 27 | +- **Recovery Metrics**: Blocking probability, recovery time, fragmentation |
| 28 | + |
| 29 | +## Code Organization Philosophy |
| 30 | + |
| 31 | +### Module Structure |
| 32 | +- Each module contains its own `tests/` subdirectory |
| 33 | +- Every module and test directory must have a `README.md` |
| 34 | +- Use `__init__.py` to define public APIs with `__all__` |
| 35 | +- Registry pattern for pluggable algorithms |
| 36 | + |
| 37 | +### Naming Conventions |
| 38 | +- **Standardized names**: `engine_props`, `sim_params`, `network_topology` |
| 39 | +- **No type suffixes**: Use type hints instead of `_dict`, `_list` suffixes |
| 40 | +- **Functions**: Verb phrases in `snake_case` |
| 41 | +- **Classes**: `PascalCase` |
| 42 | + |
| 43 | +### State Management |
| 44 | +- Use `StateWrapper` for mutable configuration objects like `engine_props` |
| 45 | +- Never hardcode paths - use `pathlib.Path` and configuration |
| 46 | +- All RNG operations must be seeded for reproducibility |
| 47 | + |
| 48 | +## Development Workflow |
| 49 | + |
| 50 | +### Quality Tools |
| 51 | +- **ruff**: Modern linting and formatting (replaces black, flake8, isort) |
| 52 | +- **mypy**: Type checking with strict configuration |
| 53 | +- **pytest**: Unit testing with coverage reporting |
| 54 | +- **pre-commit**: Automated quality checks on commit |
| 55 | + |
| 56 | +### Key Commands |
| 57 | +```bash |
| 58 | +make format # Auto-format code |
| 59 | +make lint-new # Check for issues |
| 60 | +make test-new # Run tests with coverage |
| 61 | +make check-all # Full quality check |
| 62 | +``` |
| 63 | + |
| 64 | +## Important Constraints and Guidelines |
| 65 | + |
| 66 | +### What to Avoid |
| 67 | +- No emojis in documentation or code (per user preference) |
| 68 | +- No print statements - use logging |
| 69 | +- No hardcoded paths - use configuration |
| 70 | +- No broad exception catching |
| 71 | +- No `fusion/gui` module changes (deprecated, requires revamp) |
| 72 | + |
| 73 | +### What to Follow |
| 74 | +- All functions require type annotations |
| 75 | +- All code must pass ruff and mypy checks |
| 76 | +- Functions should be under 50 lines |
| 77 | +- Files should be under 500 lines |
| 78 | +- Test coverage targets: 80-90% for most modules |
| 79 | +- Use Sphinx-style docstrings |
| 80 | + |
| 81 | +## Configuration System |
| 82 | + |
| 83 | +FUSION uses INI-based configuration with: |
| 84 | +- Template system in `fusion/configs/templates/` |
| 85 | +- CLI argument integration via `fusion/cli/run_sim.py` |
| 86 | +- Validation and type checking |
| 87 | +- Environment-specific overrides |
| 88 | + |
| 89 | +## Testing Standards |
| 90 | + |
| 91 | +### Unit Testing |
| 92 | +- Tests located in `tests/` subdirectory within each module |
| 93 | +- One test file per module: `test_<module_name>.py` |
| 94 | +- Mock all external dependencies |
| 95 | +- Follow AAA pattern (Arrange, Act, Assert) |
| 96 | +- Test naming: `test_<what>_<when>_<expected>` |
| 97 | + |
| 98 | +### Integration Testing |
| 99 | +- Located in top-level `tests/` directory |
| 100 | +- Test component interactions |
| 101 | +- May use real dependencies where appropriate |
| 102 | + |
| 103 | +## Common Patterns |
| 104 | + |
| 105 | +### Factory Pattern |
| 106 | +See `fusion/interfaces/factory.py` for algorithm instantiation |
| 107 | + |
| 108 | +### Interface/Abstract Base Classes |
| 109 | +- `AbstractRoutingAlgorithm` |
| 110 | +- `AbstractSpectrumAssigner` |
| 111 | +- `AbstractSNRMeasurer` |
| 112 | + |
| 113 | +### Registry Pattern |
| 114 | +- Algorithm registration and discovery |
| 115 | +- Plugin-style architecture |
| 116 | +- Used in `fusion/modules/*/registry.py` |
| 117 | + |
| 118 | +## Current Development Focus |
| 119 | + |
| 120 | +As of the latest commits, the project is focused on: |
| 121 | +1. Quality improvements: Resolving linting errors and test failures |
| 122 | +2. Configuration system enhancements |
| 123 | +3. Documentation improvements |
| 124 | +4. Survivability experiment features (v1) |
| 125 | +5. Offline RL policy integration |
| 126 | + |
| 127 | +## Reference Documents |
| 128 | + |
| 129 | +For detailed information, consult: |
| 130 | +- `ARCHITECTURE.md`: System architecture and design |
| 131 | +- `CODING_STANDARDS.md`: Code style and organization |
| 132 | +- `TESTING_STANDARDS.md`: Testing requirements |
| 133 | +- `DEVELOPMENT_WORKFLOW.md`: Development process and tools |
| 134 | +- `CONTRIBUTING.md`: Contribution guidelines |
| 135 | + |
| 136 | +## Working with This Codebase |
| 137 | + |
| 138 | +When making changes: |
| 139 | +1. Read relevant module READMEs first |
| 140 | +2. Check `TODO.md` files for known issues |
| 141 | +3. Follow the standardized naming conventions |
| 142 | +4. Add tests for new functionality |
| 143 | +5. Update documentation as needed |
| 144 | +6. Run `make check-all` before committing |
| 145 | +7. Use the TodoWrite tool to track multi-step tasks |
| 146 | + |
| 147 | +## Key Files to Know |
| 148 | + |
| 149 | +- `fusion/core/simulation.py`: Main simulation engine |
| 150 | +- `fusion/interfaces/factory.py`: Algorithm factory and pipeline |
| 151 | +- `fusion/cli/run_sim.py`: CLI entry point |
| 152 | +- `fusion/configs/cli_to_config.py`: Configuration processing |
| 153 | +- `fusion/modules/*/registry.py`: Algorithm registries |
| 154 | + |
| 155 | +## Domain Knowledge |
| 156 | + |
| 157 | +### Optical Networking Concepts |
| 158 | +- **Spectrum slots**: Frequency spectrum divided into assignable units |
| 159 | +- **Wavelength**: Individual optical carrier |
| 160 | +- **Modulation formats**: BPSK, QPSK, 16-QAM, etc. |
| 161 | +- **SNR (Signal-to-Noise Ratio)**: Quality metric for optical signals |
| 162 | +- **Guard bands**: Spacing between spectrum assignments |
| 163 | +- **Fragmentation**: Inefficient use of spectrum due to non-contiguous allocations |
| 164 | + |
| 165 | +### Network Survivability |
| 166 | +- **Protection**: Pre-provisioned backup resources (1+1, 1:1) |
| 167 | +- **Restoration**: Dynamic re-routing after failure |
| 168 | +- **SRLG (Shared Risk Link Group)**: Links that fail together |
| 169 | +- **Disjoint paths**: Paths sharing no common links/nodes |
| 170 | + |
| 171 | +This context should help AI assistants understand the project structure, conventions, and domain when assisting with development tasks. |
0 commit comments