GroveEngine/tests/modules
StillHammer 1b7703f07b feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch
## Breaking Change

IIO API redesigned from manual pull+if-forest to callback dispatch.
All modules must update their subscribe() calls to pass handlers.

### Before (OLD API)
```cpp
io->subscribe("input:mouse");

void process(...) {
    while (io->hasMessages()) {
        auto msg = io->pullMessage();
        if (msg.topic == "input:mouse") {
            handleMouse(msg);
        } else if (msg.topic == "input:keyboard") {
            handleKeyboard(msg);
        }
    }
}
```

### After (NEW API)
```cpp
io->subscribe("input:mouse", [this](const Message& msg) {
    handleMouse(msg);
});

void process(...) {
    while (io->hasMessages()) {
        io->pullAndDispatch();  // Callbacks invoked automatically
    }
}
```

## Changes

**Core API (include/grove/IIO.h)**
- Added: `using MessageHandler = std::function<void(const Message&)>`
- Changed: `subscribe()` now requires `MessageHandler` callback parameter
- Changed: `subscribeLowFreq()` now requires `MessageHandler` callback
- Removed: `pullMessage()`
- Added: `pullAndDispatch()` - pulls and auto-dispatches to handlers

**Implementation (src/IntraIO.cpp)**
- Store callbacks in `Subscription.handler`
- `pullAndDispatch()` matches topic against ALL subscriptions (not just first)
- Fixed: Regex pattern compilation supports both wildcards (*) and regex (.*)
- Performance: ~1000 msg/s throughput (unchanged from before)

**Files Updated**
- 31 test/module files migrated to callback API (via parallel agents)
- 8 documentation files updated (DEVELOPER_GUIDE, USER_GUIDE, module READMEs)

## Bugs Fixed During Migration

1. **pullAndDispatch() early return bug**: Was only calling FIRST matching handler
   - Fix: Loop through ALL subscriptions, invoke all matching handlers

2. **Regex pattern compilation bug**: Pattern "player:.*" failed to match
   - Fix: Detect ".*" in pattern → use as regex, otherwise escape and convert wildcards

## Testing

 test_11_io_system: PASSED (IIO pub/sub, pattern matching, batching)
 test_threaded_module_system: 6/6 PASSED
 test_threaded_stress: 5/5 PASSED (50 modules, 100x reload, concurrent ops)
 test_12_datanode: PASSED
 10 TopicTree scenarios: 10/10 PASSED
 benchmark_e2e: ~1000 msg/s throughput

Total: 23+ tests passing

## Performance Impact

No performance regression from callback dispatch:
- IIO throughput: ~1000 msg/s (same as before)
- ThreadedModuleSystem: Speedup ~1.0x (barrier pattern expected)

## Migration Guide

For all modules using IIO:

1. Update subscribe() calls to include handler lambda
2. Replace pullMessage() loops with pullAndDispatch()
3. Move topic-specific logic from if-forest into callbacks

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 14:19:27 +07:00
..
BaseModule.cpp feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
BaseModule.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
BatchModule.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
BatchModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
BroadcastModule.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
BroadcastModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
ChaosModule.cpp feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
ChaosModule.h feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
ConfigurableModule.cpp feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
ConfigurableModule.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
ConfigWatcherModule.cpp feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
ConfigWatcherModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
ConsumerModule.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
ConsumerModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
DependentModule.cpp feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
DependentModule.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
EconomyModule.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
EconomyModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
ErrorRecoveryModule.cpp feat: Add Scenario 6 - Error Recovery test suite 2025-11-17 07:14:04 +08:00
ErrorRecoveryModule.h feat: Add Scenario 6 - Error Recovery test suite 2025-11-17 07:14:04 +08:00
GameLogicModuleV1.cpp feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
GameLogicModuleV1.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
GameLogicModuleV2.cpp feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
GameLogicModuleV2.cpp.bak feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
GameLogicModuleV2.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
GameLogicModuleV3.cpp feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
GameLogicModuleV3.cpp.bak feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
GameLogicModuleV3.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
HeavyStateModule.cpp feat: Add Scenario 7 - Limit Tests with extreme conditions 2025-11-17 11:29:48 +08:00
HeavyStateModule.h feat: Add Scenario 7 - Limit Tests with extreme conditions 2025-11-17 11:29:48 +08:00
IndependentModule.cpp feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
IndependentModule.h feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
IOStressModule.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
IOStressModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
LeakTestModule.cpp feat: Add integration tests 8-10 & fix CTest configuration 2025-11-19 07:34:15 +08:00
MetricsModule.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
MetricsModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
PlayerModule.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
PlayerModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
ProducerModule.cpp feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
ProducerModule.h feat: Add Scenario 11 IO System test & fix IntraIO routing architecture 2025-11-19 11:43:08 +08:00
StressModule.cpp feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
StressModule.h feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
TankModule.cpp feat: Add comprehensive hot-reload test suite with 3 integration scenarios 2025-11-13 22:13:07 +08:00
TankModule.h fix: IntraIOManager batch thread + AutoCompiler Windows support 2025-12-31 09:44:37 +07:00
TestControllerModule.cpp feat(IIO)!: BREAKING CHANGE - Callback-based message dispatch 2026-01-19 14:19:27 +07:00
TestModule.cpp fix: Windows MinGW CTest compatibility - DLL loading and module paths 2025-12-30 20:04:44 +07:00
TestModule.h feat: Add Scenario 4 - Race Condition Hunter test suite 2025-11-15 10:55:44 +08:00