Commit Graph

7 Commits

Author SHA1 Message Date
98acb32c4c fix: Resolve deadlock in IntraIOManager + cleanup SEGFAULTs
- Fix critical deadlock in IntraIOManager using std::scoped_lock for
  multi-mutex acquisition (CrossSystemIntegration: 1901s → 4s)
- Add std::shared_mutex for read-heavy operations (TopicTree, IntraIOManager)
- Fix SEGFAULT in SequentialModuleSystem destructor (logger guard)
- Fix SEGFAULT in ModuleLoader (don't auto-unload when modules still alive)
- Fix iterator invalidation in DependencyTestEngine destructor
- Add TSan/Helgrind integration for deadlock detection
- Add coding guidelines for synchronization patterns

All 23 tests now pass (100%)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 11:36:33 +08:00
3923e3cbbe feat: Add StillHammer Logger & IntraIO batching (WIP)
- Add StillHammer Logger library (external/StillHammer/logger/)
  * Elegant wrapper around spdlog (1 line instead of 10+)
  * Auto-organize logs by domain: logs/domain/component.log
  * Snake_case conversion: NetworkIO → network_io.log
  * Thread-safe, zero-overhead, includes demo and tests

- Add IntraIO low-frequency batching infrastructure
  * BatchBuffer structure for message accumulation
  * batchFlushLoop() thread for periodic flushing
  * Pattern matching lambda for detecting low-freq subscriptions
  * WIP: test_11 scenario 4 still failing (100 batches instead of ~2)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 03:01:09 +08:00
a846ed26d7 feat: Add StillHammer TopicTree for O(k) topic routing
Replace O(n×m) regex-based pattern matching with O(k) hierarchical
hash map lookup in IntraIOManager.

## Changes

**New: StillHammer/topictree library**
- Header-only C++17 template library
- Zero-copy topic parsing with string_view
- Wildcards: `*` (single-level), `.*` (multi-level)
- Thread-safe with mutex protection
- Comprehensive test suite (10 scenarios)

**Modified: IntraIOManager**
- Replace RouteEntry vector + regex with TopicTree
- Batched logging (every 100 messages) to reduce spam
- O(k) lookup where k = topic depth (~3 segments)

## Performance

- Before: O(n patterns × m regex ops) per message
- After: O(k topic depth) per message
- Typical gain: ~33x faster for 100 patterns, depth 3

## Tests

 test_11 (scenarios 1-3): Basic routing, pattern matching, multi-module
 test_12: DataNode integration (all 6 tests pass)
⚠️  test_11 (scenario 4+): Batching feature not implemented (out of scope)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 01:31:50 +08:00
ddbed30ed7 feat: Add Scenario 11 IO System test & fix IntraIO routing architecture
Implémentation complète du scénario 11 (IO System Stress Test) avec correction majeure de l'architecture de routing IntraIO.

## Nouveaux Modules de Test (Scenario 11)
- ProducerModule: Publie messages pour tests IO
- ConsumerModule: Consomme et valide messages reçus
- BroadcastModule: Test multi-subscriber broadcasting
- BatchModule: Test low-frequency batching
- IOStressModule: Tests de charge concurrents

## Test d'Intégration
- test_11_io_system.cpp: 6 tests validant:
  * Basic Publish-Subscribe
  * Pattern Matching avec wildcards
  * Multi-Module Routing (1-to-many)
  * Low-Frequency Subscriptions (batching)
  * Backpressure & Queue Overflow
  * Thread Safety (concurrent pub/pull)

## Fix Architecture Critique: IntraIO Routing
**Problème**: IntraIO::publish() et subscribe() n'utilisaient PAS IntraIOManager pour router entre modules.

**Solution**: Utilisation de JSON comme format de transport intermédiaire
- IntraIO::publish() → extrait JSON → IntraIOManager::routeMessage()
- IntraIO::subscribe() → enregistre au IntraIOManager::registerSubscription()
- IntraIOManager::routeMessage() → copie JSON pour chaque subscriber → deliverMessage()

**Bénéfices**:
-  Routing centralisé fonctionnel
-  Support 1-to-many (copie JSON au lieu de move unique_ptr)
-  Pas besoin d'implémenter IDataNode::clone()
-  Compatible futur NetworkIO (JSON sérialisable)

## Modules Scenario 13 (Cross-System)
- ConfigWatcherModule, PlayerModule, EconomyModule, MetricsModule
- test_13_cross_system.cpp (stub)

## Documentation
- CLAUDE_NEXT_SESSION.md: Instructions détaillées pour build/test

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 11:43:08 +08:00
4659c17340 feat: Complete migration from json to IDataNode API
Migrated all implementations to use the new IDataNode abstraction layer:

Core Changes:
- Added spdlog dependency via FetchContent for comprehensive logging
- Enabled POSITION_INDEPENDENT_CODE for grove_impl (required for .so modules)
- Updated all factory createFromConfig() methods to accept IDataNode instead of json
- Replaced json parameters with std::unique_ptr<IDataNode> throughout

Migrated Files (8 core implementations):
- IntraIO: Complete rewrite with IDataNode API and move semantics
- IntraIOManager: Updated message routing with unique_ptr delivery
- SequentialModuleSystem: Migrated to IDataNode input/task handling
- IOFactory: Changed config parsing to use IDataNode getters
- ModuleFactory: Updated all config methods
- EngineFactory: Updated all config methods
- ModuleSystemFactory: Updated all config methods
- DebugEngine: Migrated debug output to IDataNode

Testing Infrastructure:
- Added hot-reload test (TestModule.so + test_hotreload executable)
- Validated 0.012ms hot-reload performance
- State preservation across module reloads working correctly

Technical Details:
- Used JsonDataNode/JsonDataTree as IDataNode backend (nlohmann::json)
- Changed all json::operator[] to getString()/getInt()/getBool()
- Implemented move semantics for unique_ptr<IDataNode> message passing
- Note: IDataNode::clone() not implemented yet (IntraIOManager delivers to first match only)

All files now compile successfully with 100% IDataNode API compliance.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 07:17:06 +08:00
fad105afb2 feat: Implement complete IDataNode/IDataTree system with JSON backend
Major feature: Unified config/data/runtime tree system

**New System Architecture:**
- Unified data tree for config, persistent data, and runtime state
- Three separate roots: config/ (read-only + hot-reload), data/ (read-write + save), runtime/ (temporary)
- Support for modding, saves, and hot-reload in single system

**Interfaces:**
- IDataValue: Abstract data value interface (type-safe access)
- IDataNode: Tree node with navigation, search, and modification
- IDataTree: Root container with config/data/runtime management

**Concrete Implementations:**
- JsonDataValue: nlohmann::json backed value
- JsonDataNode: Full tree navigation with pattern matching & queries
- JsonDataTree: File-based JSON storage with hot-reload

**Features:**
- Pattern matching search (wildcards support)
- Property-based queries with predicates
- SHA256 hashing for validation/sync
- Hot-reload for config/ directory
- Save operations for data/ persistence
- Read-only enforcement for config/

**API Changes:**
- All namespaces changed from 'warfactory' to 'grove'
- IDataTree: Added getConfigRoot(), getDataRoot(), getRuntimeRoot()
- IDataTree: Added saveData(), saveNode() for persistence
- IDataNode: Added setChild(), removeChild(), clearChildren()
- CMakeLists.txt: Added OpenSSL dependency for hashing

**Usage:**
```cpp
auto tree = DataTreeFactory::create("json", "./gamedata");
auto config = tree->getConfigRoot();     // Read-only game config
auto data = tree->getDataRoot();         // Player saves
auto runtime = tree->getRuntimeRoot();   // Temporary state

// Hot-reload config on file changes
if (tree->reloadIfChanged()) { /* refresh modules */ }

// Save player progress
data->setChild("progress", progressNode);
tree->saveData();
```

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 15:36:25 +08:00
e1cfa4513e Initial commit: Grove Engine core architecture
- Core interfaces for modular engine system
- Resource management and registry system
- Module system with sequential execution
- ImGui-based UI implementation
- Intra-process I/O communication
- Data tree structures for hierarchical data
- Serialization framework
- Task scheduler interface
- Debug engine implementation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 00:19:15 +08:00