Go to file
StillHammer d8c5f93429 feat: Add comprehensive hot-reload test suite with 3 integration scenarios
This commit implements a complete test infrastructure for validating
hot-reload stability and robustness across multiple scenarios.

## New Test Infrastructure

### Test Helpers (tests/helpers/)
- TestMetrics: FPS, memory, reload time tracking with statistics
- TestReporter: Assertion tracking and formatted test reports
- SystemUtils: Memory usage monitoring via /proc/self/status
- TestAssertions: Macro-based assertion framework

### Test Modules
- TankModule: Realistic module with 50 tanks for production testing
- ChaosModule: Crash-injection module for robustness validation
- StressModule: Lightweight module for long-duration stability tests

## Integration Test Scenarios

### Scenario 1: Production Hot-Reload (test_01_production_hotreload.cpp)
 PASSED - End-to-end hot-reload validation
- 30 seconds simulation (1800 frames @ 60 FPS)
- TankModule with 50 tanks, realistic state
- Source modification (v1.0 → v2.0), recompilation, reload
- State preservation: positions, velocities, frameCount
- Metrics: ~163ms reload time, 0.88MB memory growth

### Scenario 2: Chaos Monkey (test_02_chaos_monkey.cpp)
 PASSED - Extreme robustness testing
- 150+ random crashes per run (5% crash probability per frame)
- 5 crash types: runtime_error, logic_error, out_of_range, domain_error, state corruption
- 100% recovery rate via automatic hot-reload
- Corrupted state detection and rejection
- Random seed for unpredictable crash patterns
- Proof of real reload: temporary files in /tmp/grove_module_*.so

### Scenario 3: Stress Test (test_03_stress_test.cpp)
 PASSED - Long-duration stability validation
- 10 minutes simulation (36000 frames @ 60 FPS)
- 120 hot-reloads (every 5 seconds)
- 100% reload success rate (120/120)
- Memory growth: 2 MB (threshold: 50 MB)
- Avg reload time: 160ms (threshold: 500ms)
- No memory leaks, no file descriptor leaks

## Core Engine Enhancements

### ModuleLoader (src/ModuleLoader.cpp)
- Temporary file copy to /tmp/ for Linux dlopen cache bypass
- Robust reload() method: getState() → unload() → load() → setState()
- Automatic cleanup of temporary files
- Comprehensive error handling and logging

### DebugEngine (src/DebugEngine.cpp)
- Automatic recovery in processModuleSystems()
- Exception catching → logging → module reload → continue
- Module state dump utilities for debugging

### SequentialModuleSystem (src/SequentialModuleSystem.cpp)
- extractModule() for safe module extraction
- registerModule() for module re-registration
- Enhanced processModules() with error handling

## Build System
- CMake configuration for test infrastructure
- Shared library compilation for test modules (.so)
- CTest integration for all scenarios
- PIC flag management for spdlog compatibility

## Documentation (planTI/)
- Complete test architecture documentation
- Detailed scenario specifications with success criteria
- Global test plan and validation thresholds

## Validation Results
All 3 integration scenarios pass successfully:
- Production hot-reload: State preservation validated
- Chaos Monkey: 100% recovery from 150+ crashes
- Stress Test: Stable over 120 reloads, minimal memory growth

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 22:13:07 +08:00
docs docs: Add complete IDataTree system architecture documentation 2025-10-28 16:18:15 +08:00
include/grove feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
planTI feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
src feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
tests feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
CMakeLists.txt feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
README.md Initial commit: Grove Engine core architecture 2025-10-28 00:19:15 +08:00

GroveEngine 🌳

Modular C++ Engine Architecture for Rapid Development with Hot-Reload

GroveEngine is a lightweight, modular engine architecture designed for blazing-fast development iteration (0.4ms hot-reload validated) and optimized for Claude Code workflows.

Key Features

  • 🔥 Hot-Reload 0.4ms - Validated blazing-fast module reloading
  • 🧩 Modular Architecture - Clean separation via interfaces (IEngine, IModule, IIO, IModuleSystem)
  • 🚀 Development Velocity - Edit → Build → Hot-reload < 1 second total
  • 🤖 Claude Code Optimized - 200-300 line modules for AI-friendly development
  • 📦 Autonomous Builds - Each module builds independently (cmake .)
  • 🔌 Progressive Scaling - Debug → Production → Cloud without rewriting

Architecture Overview

grove::IEngine (Orchestration)
├── grove::IModuleSystem (Execution strategy)
│   ├── SequentialModuleSystem (Debug/test - 1 module at a time)
│   ├── ThreadedModuleSystem (Each module in thread - TODO)
│   └── MultithreadedModuleSystem (Thread pool - TODO)
├── grove::IModule (Business logic - 200-300 lines)
│   └── Your modules (.so/.dll hot-reloadable)
└── grove::IIO (Communication)
    ├── IntraIO (Same process - validated)
    ├── LocalIO (Same machine - TODO)
    └── NetworkIO (Distributed - TODO)

Current Status

Implemented & Validated

  • Core Interfaces (13): IEngine, IModule, IModuleSystem, IIO, ICoordinationModule, ITaskScheduler, IDataTree, IDataNode, IUI, ISerializable
  • Debug Implementations (Phase 2 - Pre-IDataTree):
    • DebugEngine - Comprehensive logging and health monitoring
    • SequentialModuleSystem - Ultra-lightweight execution
    • IntraIO + IntraIOManager - Sub-millisecond pub/sub with pattern matching
    • ModuleFactory - Dynamic .so/.dll loading system
    • EngineFactory, ModuleSystemFactory, IOFactory - Factory patterns
  • Hot-Reload System - 0.4ms average, 0.055ms best performance, perfect state preservation
  • UI System - ImGuiUI implementation with hybrid sizing

⚠️ Compatibility Note

Current implementations use pre-IDataTree API (json config). The architecture evolved to use IDataNode for configuration. Implementations need adaptation or recreation for full IDataTree compatibility.

🚧 TODO

  • Adapt implementations to use IDataTree/IDataNode instead of json
  • Implement ThreadedModuleSystem and MultithreadedModuleSystem
  • Implement LocalIO and NetworkIO
  • Create concrete IDataTree implementations (JSONDataTree, etc.)

Quick Start

Directory Structure

GroveEngine/
├── include/grove/          # 27 headers
│   ├── IEngine.h          # Core interfaces
│   ├── IModule.h
│   ├── IModuleSystem.h
│   ├── IIO.h
│   ├── IDataTree.h        # Configuration system
│   ├── IDataNode.h
│   └── ...
├── src/                    # 10 implementations
│   ├── DebugEngine.cpp
│   ├── SequentialModuleSystem.cpp
│   ├── IntraIO.cpp
│   ├── ModuleFactory.cpp
│   └── ...
├── docs/                   # Documentation
│   ├── architecture/
│   │   ├── architecture-modulaire.md
│   │   └── claude-code-integration.md
│   └── implementation/
│       └── CLAUDE-HOT-RELOAD-GUIDE.md
├── modules/                # Your application modules
├── tests/                  # Tests
└── CMakeLists.txt         # Build system

Build

cd GroveEngine
mkdir build && cd build
cmake ..
make

# Or use the root CMakeLists.txt directly
cmake .
make

Create a Module

// MyModule.h
#include <grove/IModule.h>

class MyModule : public grove::IModule {
public:
    json process(const json& input) override {
        // Your logic here (200-300 lines max)
        return {"result": "processed"};
    }

    void setConfiguration(const IDataNode& config, IIO* io, ITaskScheduler* scheduler) override {
        // Configuration setup
    }

    // ... other interface methods
};

Documentation

Philosophy

Micro-Context Development

  • Small modules (200-300 lines) for AI-friendly development
  • Autonomous builds - Zero parent dependencies
  • Hot-swappable infrastructure - Change performance without touching business logic

Progressive Evolution

// Start simple (MVP)
DebugEngine + SequentialModuleSystem + IntraIO

// Scale transparently (same module code)
HighPerfEngine + MultithreadedModuleSystem + NetworkIO

Complexity Through Simplicity

Complex behavior emerges from the interaction of simple, well-defined modules.

Performance

Hot-Reload Benchmarks (Validated):

  • Average: 0.4ms
  • Best: 0.055ms
  • 5-cycle test: 2ms total
  • State persistence: 100% success rate
  • Classification: 🚀 BLAZING (Theoretical maximum achieved)

Projects Using GroveEngine

  • AISSIA - AI Smart Schedule & Interactive Assistant (in development)
  • WarFactory (original architecture source)

License

To be defined

Contributing

This engine uses an architecture optimized for Claude Code development. Each module is autonomous and can be developed independently.

Constraints:

  • Modules 200-300 lines maximum
  • Autonomous build: cmake . from module directory
  • JSON-only communication between modules
  • Zero dependencies up (no #include "../")
  • Never cmake ..

GroveEngine - Where modules grow like trees in a grove 🌳