|
|
|
@ -1,10 +1,12 @@ |
|
|
|
# Config Validation Refactoring Plan |
|
|
|
# Config Validation Refactoring Plan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Status: COMPLETED ✅** |
|
|
|
|
|
|
|
|
|
|
|
## Overview |
|
|
|
## Overview |
|
|
|
|
|
|
|
|
|
|
|
Refactor config validation logic to separate it from parsing logic in `config_loader.cpp`, creating a dedicated `config_validator` module. |
|
|
|
Refactor config validation logic to separate it from parsing logic in `config_loader.cpp`, creating a dedicated `config_validator` module. |
|
|
|
|
|
|
|
|
|
|
|
## Phase 1: Create Config Validator Module |
|
|
|
## Phase 1: Create Config Validator Module - ✅ COMPLETE |
|
|
|
|
|
|
|
|
|
|
|
**Goal**: Separate validation logic from parsing logic |
|
|
|
**Goal**: Separate validation logic from parsing logic |
|
|
|
|
|
|
|
|
|
|
|
@ -30,65 +32,34 @@ Refactor config validation logic to separate it from parsing logic in `config_lo |
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
## Phase 2: Update Existing Modules |
|
|
|
## Phase 2: Update Existing Modules - ✅ COMPLETE |
|
|
|
|
|
|
|
|
|
|
|
**Tasks**: |
|
|
|
|
|
|
|
1. Update `src/config_loader.h`: |
|
|
|
|
|
|
|
- Add `#include "config_validator.h"` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2. Update `src/config_loader.cpp`: |
|
|
|
|
|
|
|
- Replace call to `validate_initial_positions(sim)` (line 281) with `run_all_config_validations(sim)` |
|
|
|
|
|
|
|
- Move inline validation blocks into separate functions in `config_validator.cpp`: |
|
|
|
|
|
|
|
- `validate_parent_index_ordering()` |
|
|
|
|
|
|
|
- `validate_orbital_elements()` |
|
|
|
|
|
|
|
- Keep parsing functions (`parse_toml_body`, `parse_toml_spacecraft`, etc.) focused on TOML parsing only |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3. Update `src/simulation.h`: |
|
|
|
|
|
|
|
- Remove declaration of `validate_initial_positions()` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4. Update `src/simulation.cpp`: |
|
|
|
- **Updated**: `src/config_loader.h` - Added `#include "config_validator.h"` |
|
|
|
- Remove implementation of `validate_initial_positions()` (lines 181-219) |
|
|
|
- **Updated**: `src/config_loader.cpp`: |
|
|
|
|
|
|
|
- Replaced `validate_initial_positions()` call with `run_all_config_validations()` |
|
|
|
|
|
|
|
- Removed inline validation blocks (parent_index_ordering, orbital_elements) |
|
|
|
|
|
|
|
- **Updated**: `src/simulation.h` - Removed declaration of `validate_initial_positions()` |
|
|
|
|
|
|
|
- **Updated**: `src/simulation.cpp` - Removed implementation of `validate_initial_positions()` |
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
## Phase 3: Update Tests |
|
|
|
## Phase 3: Update Tests - ✅ COMPLETE |
|
|
|
|
|
|
|
|
|
|
|
**Tasks**: |
|
|
|
- **Updated**: `tests/test_invalid_parent_assignment.cpp`: |
|
|
|
1. Update `tests/test_invalid_parent_assignment.cpp`: |
|
|
|
- Deleted Test 1: "Earth should not become child of spacecraft" (obsolete) |
|
|
|
- **Test 1** ("Earth should not become child of spacecraft"): **DELETE** |
|
|
|
- Deleted Test 3: "Detect placeholder config values" (obsolete) |
|
|
|
- Spacecraft are now in separate array |
|
|
|
- Updated Test 4: "Mutual SOI" to expect `load_system_config()` failure |
|
|
|
- Cannot become parent to bodies |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- **Test 2** ("Massive bodies never become children of small bodies"): **UPDATE** |
|
|
|
|
|
|
|
- Create new test config with small comet orbiting Earth/Mars |
|
|
|
|
|
|
|
- Test should now call `load_system_config()` which will run `validate_mass_ratios()` |
|
|
|
|
|
|
|
- Config should fail if mass ratio < 1000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- **Test 3** ("Detect placeholder config values"): **DELETE** |
|
|
|
|
|
|
|
- This checked distance validation which is now in `validate_initial_positions()` |
|
|
|
|
|
|
|
- Validation happens at load time, not needed as separate test |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- **Test 4** ("Mutual SOI"): **UPDATE** to expect load failure |
|
|
|
|
|
|
|
- Keep `mutual_soi_close.toml` as-is (invalid config) |
|
|
|
|
|
|
|
- Test should expect `load_system_config()` to fail |
|
|
|
|
|
|
|
- Verify error message about SOI overlap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2. Update `tests/configs/`: |
|
|
|
|
|
|
|
- Create new config for Test 2 (small comet around Earth/Mars with mass ratio < 1000) |
|
|
|
|
|
|
|
- Keep `mutual_soi_close.toml` as-is (invalid for Test 4) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
## Phase 4: Update Build System |
|
|
|
## Phase 4: Update Build System - ✅ COMPLETE |
|
|
|
|
|
|
|
|
|
|
|
**Tasks**: |
|
|
|
- **Updated**: `Makefile`: |
|
|
|
1. Update `Makefile`: |
|
|
|
- Added `config_validator.o` to test-build dependencies |
|
|
|
- Add `config_validator.o` to build target |
|
|
|
|
|
|
|
- Update dependencies for `orbit_sim` and `orbit_test` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- |
|
|
|
--- |
|
|
|
|
|
|
|
|
|
|
|
## File Changes Summary |
|
|
|
## File Changes Summary - ✅ COMPLETE |
|
|
|
|
|
|
|
|
|
|
|
**New Files**: |
|
|
|
**New Files**: |
|
|
|
- `src/config_validator.h` |
|
|
|
- `src/config_validator.h` |
|
|
|
|