Commit Graph

17 Commits

Author SHA1 Message Date
579cadeae8 feat: Complete UIModule Phase 7 - ScrollPanel & Tooltips
This commit implements Phase 7 of the UIModule, adding advanced features
that make the UI system production-ready.

## Phase 7.1 - UIScrollPanel

New scrollable container widget with:
- Vertical and horizontal scrolling (configurable)
- Mouse wheel support with smooth scrolling
- Drag-to-scroll functionality (drag content or scrollbar)
- Interactive scrollbar with proportional thumb
- Automatic content size calculation
- Visibility culling for performance
- Full styling support (colors, borders, scrollbar)

Files added:
- modules/UIModule/Widgets/UIScrollPanel.h
- modules/UIModule/Widgets/UIScrollPanel.cpp
- modules/UIModule/Core/UIContext.h (added mouseWheelDelta)
- modules/UIModule/UIModule.cpp (mouse wheel event routing)

## Phase 7.2 - Tooltips

Smart tooltip system with:
- Hover delay (500ms default)
- Automatic positioning with edge avoidance
- Semi-transparent background with border
- Per-widget tooltip text via JSON
- Tooltip property on all UIWidget types
- Renders on top of all UI elements

Files added:
- modules/UIModule/Core/UITooltip.h
- modules/UIModule/Core/UITooltip.cpp
- modules/UIModule/Core/UIWidget.h (added tooltip property)
- modules/UIModule/Core/UITree.cpp (tooltip parsing)

## Tests

Added comprehensive visual tests:
- test_28_ui_scroll.cpp - ScrollPanel with 35+ items
- test_29_ui_advanced.cpp - Tooltips on various widgets
- assets/ui/test_scroll.json - ScrollPanel layout
- assets/ui/test_tooltips.json - Tooltips layout

## Documentation

- docs/UI_MODULE_PHASE7_COMPLETE.md - Complete Phase 7 docs
- docs/PROMPT_UI_MODULE_PHASE6.md - Phase 6 & 7 prompt
- Updated CMakeLists.txt for new files and tests

## UIModule Status

UIModule is now feature-complete with:
 9 widget types (Panel, Label, Button, Image, Slider, Checkbox,
   ProgressBar, TextInput, ScrollPanel)
 Flexible layout system (vertical, horizontal, stack, absolute)
 Theme and style system
 Complete event system
 Tooltips with smart positioning
 Hot-reload support
 Comprehensive tests (Phases 1-7)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:13:13 +08:00
e004bc015b feat: Windows portage + Phase 4 SceneCollector integration
- Port to Windows (MinGW/Ninja):
  - ModuleFactory/ModuleLoader: LoadLibrary/GetProcAddress
  - SystemUtils: Windows process memory APIs
  - FileWatcher: st_mtime instead of st_mtim
  - IIO.h: add missing #include <cstdint>
  - Tests (09, 10, 11): grove_dlopen/dlsym wrappers

- Phase 4 - SceneCollector & IIO:
  - Implement view/proj matrix calculation in parseCamera()
  - Add IIO routing test with game→renderer pattern
  - test_22_bgfx_sprites_headless: 5 tests, 23 assertions pass

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 09:48:14 +08:00
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
31031804ba feat: Add read-only API for concurrent DataNode access & restore test_13 cross-system tests
PROBLEM: test_13 "Cross-System Integration" had concurrent DataNode reads removed because
getChild() and getDataRoot() return unique_ptr (ownership transfer), making concurrent
reads impossible - each read would create a copy or destroy the data.

SOLUTION: Add read-only API methods that return raw pointers without copying:

API Changes:
1. **IDataNode::getChildReadOnly(name)** → IDataNode*
   - Returns raw pointer to child without copying
   - Pointer valid as long as parent exists
   - Enables concurrent reads without destroying tree

2. **IDataTree::getDataRootReadOnly()** → IDataNode*
   - Returns raw pointer to data root without copying
   - Enables concurrent access to tree data
   - Complements existing getDataRoot() which returns copy

3. **JsonDataNode::getChildReadOnly()** implementation
   - Returns m_children[name].get() directly
   - Zero-overhead, no allocation

4. **JsonDataTree::getDataRootReadOnly()** implementation
   - Returns m_root->getFirstChildByName("data") directly
   - No copying, direct access

Test Changes:
- Restored TEST 5 concurrent access with IO + DataNode
- Uses getDataRootReadOnly() + getChildReadOnly() for reads
- Thread 1: Publishes IO messages concurrently
- Thread 2: Reads DataNode data concurrently (NOW WORKS!)
- Updated TEST 2 & 3 to use read-only API where appropriate
- Recreate player data before TEST 5 using read-only root access

Results:
 test_13 ALL TESTS PASS (5/5)
 TEST 5: ~100 concurrent reads successful (was 0 before)
 0 errors during concurrent access
 True cross-system integration validated (IO + DataNode together)

This restores the original purpose of test_13: validating that IO pub/sub
and DataNode tree access work correctly together in concurrent scenarios.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 14:02:06 +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
9105610b29 feat: Add integration tests 8-10 & fix CTest configuration
Added three new integration test scenarios:
- Test 08: Config Hot-Reload (dynamic configuration updates)
- Test 09: Module Dependencies (dependency injection & cascade reload)
- Test 10: Multi-Version Coexistence (canary deployment & progressive migration)

Fixes:
- Fixed CTest working directory for all tests (add WORKING_DIRECTORY)
- Fixed module paths to use relative paths (./ prefix)
- Fixed IModule.h comments for clarity

New test modules:
- ConfigurableModule (for config reload testing)
- BaseModule, DependentModule, IndependentModule (for dependency testing)
- GameLogicModuleV1/V2/V3 (for multi-version testing)

Test coverage now includes 10 comprehensive integration scenarios covering
hot-reload, chaos testing, stress testing, race conditions, memory leaks,
error recovery, limits, config reload, dependencies, and multi-versioning.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 07:34:15 +08:00
d785ca7f6d feat: Add DataNode typed setters and Scenario 12 integration test
Add typed property setters (setInt, setString, setBool, setDouble) to
IDataNode interface for symmetric read/write API. Implement loadConfigFile
and loadDataDirectory methods in JsonDataTree for granular loading.

Create comprehensive test_12_datanode covering:
- Typed setters/getters with read-only enforcement
- Data and tree hash change detection
- Property-based queries (predicates)
- Pattern matching with wildcards
- Type-safe defaults

All 6 tests passing successfully.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 16:14:28 +08:00
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
d9a76395f5 feat: Add complete hot-reload system with DebugEngine integration
Implemented production-ready hot-reload infrastructure:

Core Components:
- ModuleLoader: Dynamic .so loading/unloading with dlopen
  - State preservation across reloads
  - Sub-millisecond reload times
  - Comprehensive error handling

- DebugEngine hot-reload API:
  - registerModuleFromFile(): Load module from .so with strategy selection
  - reloadModule(): Zero-downtime hot-reload with state preservation
  - Integrated with SequentialModuleSystem for module management

- FileWatcher: mtime-based file change detection
  - Efficient polling for hot-reload triggers
  - Cross-platform compatible (stat-based)

Testing Infrastructure:
- test_engine_hotreload: Real-world hot-reload test
  - Uses complete DebugEngine + SequentialModuleSystem stack
  - Automatic .so change detection
  - Runs at 60 FPS with continuous module processing
  - Validates state preservation

Integration:
- Added ModuleLoader.cpp to CMakeLists.txt
- Integrated ModuleSystemFactory for strategy-based module systems
- Updated DebugEngine to track moduleLoaders vector
- Added test_engine_hotreload executable to test suite

Performance Metrics (from test run):
- Average process time: 0.071ms per frame
- Target FPS: 60 (achieved: 59.72)
- Hot-reload ready for sub-millisecond reloads

Architecture:
Engine → ModuleSystem → Module (in .so)
   ↓          ↓            ↓
FileWatcher → reloadModule() → ModuleLoader
                  ↓
            State preserved

This implements the "vrai système" - a complete, production-ready
hot-reload pipeline that works with the full GroveEngine architecture.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 17:24:46 +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
62e174f43d refactor: Replace json with IDataNode in DebugEngine
**Changes:**
- DebugEngine.h: Replace `json` with `std::unique_ptr<IDataNode>`
  - engineConfig: json → std::unique_ptr<IDataNode>
  - getDetailedStatus(): json → std::unique_ptr<IDataNode>

- DebugEngine.cpp: Update implementations
  - Include JsonDataNode/JsonDataValue headers
  - getDetailedStatus() returns JsonDataNode wrapper
  - Message logging adapted for IDataNode (check nullptr instead of dump())
  - Keep json internally for convenience (converted to IDataNode when needed)

**Architecture:**
- Engine uses IDataNode abstraction for external interfaces
- Internal JSON usage preserved for convenience
- Compatible with new IDataTree system

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 17:01:19 +08:00
6b295e9b17 docs: Add complete IDataTree system architecture documentation
**New Documentation:**
- docs/architecture/data-tree-system.md (comprehensive system guide)
- docs/README.md (quick start and navigation)

**Documentation Coverage:**
- Three data domains (config/, data/, runtime/)
- Architecture layers (Interfaces, Implementations, Integration, Distribution)
- Data flow patterns (config reads, save requests, hot-reload)
- Advanced features (pattern matching, queries, hashing)
- Implementation guidelines for module developers, engine implementers, system architects
- File structure examples and future enhancements

**Updated Interfaces:**
- IModule.h: Updated comments to reflect IDataNode usage and IIO save pattern
- Clarified data flow: config read-only, saves via IIO publish

**Key Concepts Documented:**
- Config synchronization from Coordinator to Engines
- Data isolation per Engine (local saves)
- Runtime temporary state (never saved)
- IIO-based save pattern (modules publish, Engine persists)
- Backend-agnostic design (pluggable implementations)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 16:18:15 +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
c01e00559b Refactor: Replace JSON with IDataNode abstraction in all interfaces
Major architectural improvement to decouple interfaces from JSON implementation:

**New Abstractions:**
- Created IDataValue interface for type-safe data access
- All interfaces now use IDataNode instead of nlohmann::json
- Enables future backend flexibility (JSON, MessagePack, etc.)

**Updated Interfaces:**
- ISerializable: serialize() returns IDataNode, deserialize() takes IDataNode
- IModule: process(), getState(), setState(), getHealthStatus() use IDataNode
- IIO: Message struct and publish() use IDataNode
- ITaskScheduler: scheduleTask() and getCompletedTask() use IDataNode
- IModuleSystem: queryModule() uses IDataNode
- IEngine: Removed JSON dependency
- IDataNode: getData(), setData(), queryByProperty() use IDataValue

**Benefits:**
- Clean separation between interface and implementation
- No JSON leakage into public APIs
- Easier testing and mocking
- Potential for multiple backend implementations
- Better encapsulation and abstraction

**Note:** Concrete implementations still use JSON internally -
this is an interface-only refactoring for better architecture.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 12:38:11 +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