Skip to content

Claude/State validator#385

Merged
Krilliac merged 9 commits intoWorkingfrom
claude/code-review-fixes-a8crX
Apr 5, 2026
Merged

Claude/State validator#385
Krilliac merged 9 commits intoWorkingfrom
claude/code-review-fixes-a8crX

Conversation

@Krilliac
Copy link
Copy Markdown
Owner

@Krilliac Krilliac commented Apr 5, 2026

No description provided.

claude added 4 commits April 5, 2026 21:22
…ards

- NetworkConnection: add m_replicationMutex lock when iterating
  m_replicatedEntities in HandleDisconnect and CheckConnectionTimeouts;
  move m_clientAddresses.erase inside m_clientsMutex scope
- FBXImporter: add sanity limits on string length (16 MB) and array
  count (64M elements) to prevent OOM from malformed files; use
  size_t casts for multiplication to prevent overflow
- EditorTheme: add exception logging to ExportTheme/ImportTheme catch
  blocks instead of silently returning false
- JSONSceneSerializer: remove partial file on write failure and log error
- ScriptSandbox: add default case to security level switch (falls back
  to Strict with a warning)
- AnimationSystem: add default case to IK type switch with warning
- FormationSystem: add default case to formation type switch with warning
- MaterialConsoleOps: replace .at() with .find() to prevent
  std::out_of_range exception

https://claude.ai/code/session_014UVmjuGivyfHqgF5UhWKei
- Profiler: check HRESULT return values from CreateQuery; reset query
  ComPtrs and return early on failure to prevent null pointer dereference
- GamepadInput: guard NormalizeTrigger against division by zero when
  trigger threshold equals 1.0

https://claude.ai/code/session_014UVmjuGivyfHqgF5UhWKei
- SparkPakWriter: check all fwrite() return values via writeBytes helper;
  log and close file on any write failure to prevent silent archive
  corruption (disk full, permission errors, etc.)
- Terrain: validate seekg/read success when loading heightmap BMP data;
  log and return E_FAIL on failure instead of using garbage data
- PrefabAsset: check file.good() after write sequence to detect stream
  errors before reporting success

https://claude.ai/code/session_014UVmjuGivyfHqgF5UhWKei
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

Code Coverage (GCC + lcov)

Utils/MathUtils.cpp                            |    -     0|    -   0|    -    0
Utils/MemoryDebugger.h                         |13.3%   150| 0.0%  20|    -    0
Utils/MemoryMonitor.cpp                        | 9.6%   229| 0.0%  19|    -    0
Utils/MemoryMonitor.h                          |85.7%    14| 0.0%  12|    -    0
Utils/MultiISA.h                               |42.9%    14| 0.0%   6|    -    0
Utils/NetworkHealthMonitor.cpp                 | 113%    15| 0.0%   2|    -    0
Utils/NetworkHealthMonitor.h                   |    -     0|    -   0|    -    0
Utils/OpaqueHandle.h                           | 209%    11| 0.0%  15|    -    0
Utils/Profiler.cpp                             |14.2%   113| 0.0%  15|    -    0
Utils/Profiler.h                               |36.4%    33| 0.0%  12|    -    0
Utils/RandomEngine.h                           |29.3%    41| 0.0%  12|    -    0
Utils/Result.h                                 | 100%    29| 0.0%  28|    -    0
Utils/RingBuffer.h                             | 108%    59| 0.0%  64|    -    0
Utils/ScopeGuard.h                             | 142%    36| 0.0%  51|    -    0
Utils/ScopedTimer.h                            |25.0%    12| 0.0%   3|    -    0
Utils/Serializer.h                             | 100%    48| 0.0%  42|    -    0
Utils/SparkConsole.cpp                         |93.2%    44| 0.0%   7|    -    0
Utils/SparkConsole.h                           | 100%     2| 0.0%   2|    -    0
Utils/SparkError.h                             |10.9%    55| 0.0%   6|    -    0
Utils/SplinePath.h                             |    -     0|    -   0|    -    0
Utils/StackTrace.h                             |11.0%    73| 0.0%   8|    -    0
Utils/StateMachine.h                           |54.0%    63| 0.0%  32|    -    0
Utils/StringUtils.h                            |18.8%   112| 0.0%  21|    -    0
Utils/Telemetry.h                              |21.8%    87| 0.0%  16|    -    0
Utils/ThreadDebugger.h                         |12.8%   148| 0.0%  19|    -    0
Utils/ThreadSafeQueue.h                        |27.5%    40| 0.0%  11|    -    0
Utils/UUID.h                                   |43.2%    37| 0.0%  16|    -    0
Utils/Validate.h                               |    -     0|    -   0|    -    0

[/home/runner/work/SparkEngine/SparkEngine/SparkSDK/Include/Spark/]
IEngineContext.h                               |6700%     1| 0.0%   1|    -    0
Version.h                                      |    -     0|    -   0|    -    0
================================================================================
                                         Total:|31.3% 15823| 0.0%  2k|    -    0

claude added 5 commits April 5, 2026 21:59
New system that periodically scans ECS entities for impossible state
combinations — analogous to MMO server-side movement validation that
detects desync bugs (e.g., "swimming on land").

Follows the existing detector pattern (singleton, Init/Update/Shutdown,
console commands, config struct, shipping-safe macro).

18 validation rules across 7 categories:
- Health: isDead vs health, deathProcessed consistency, AI death sync
- Physics: static body velocity, dynamic body zero mass
- AI: combat/fleeing without target, dead AI with target
- Interaction: destroyed with uses, expired cooldown state
- Network: duplicate networkIDs
- Ragdoll: animated mode with blend weight
- Destructible: health/stage desync, cover point over-occupancy

Timer-based checks (default 1s interval, not per-frame). Game modules
can register additional domain-specific rules via AddRule().

Console commands: state.status, state.rules, state.violations, state.config

https://claude.ai/code/session_014UVmjuGivyfHqgF5UhWKei
Each game module now registers domain-specific state validation rules
during initialization via InvalidStateDetector::AddRule():

- SparkGameFPS (2): dead entity moving, dead AI in combat/alert
- SparkGameMMO (2): dead network entity unprocessed, health over max
- SparkGameRPG (2): dead NPC patrolling, negative health
- SparkGameARPG (2): dead mob with target, dead entity high-speed
- SparkGameRTS (2): dead unit attacking, idle unit with target
- SparkGameRacing (1): static body with velocity
- SparkGamePlatformer (1): dead entity moving horizontally
- SparkGameOpenWorld (2): dead wildlife patrolling, zero maxHealth
- SparkGame (1): health significantly exceeding maxHealth
- SparkGameVisualScript (1): dead entity with unprocessed death

Total: 16 game-module rules + 18 core engine rules = 34 rules

https://claude.ai/code/session_014UVmjuGivyfHqgF5UhWKei
Replace em-dash with comma in RTS.IdleWithTarget rule description
to avoid rendering issues in diff views.

https://claude.ai/code/session_014UVmjuGivyfHqgF5UhWKei
@Krilliac Krilliac merged commit 7f12e03 into Working Apr 5, 2026
40 checks passed
@Krilliac Krilliac deleted the claude/code-review-fixes-a8crX branch April 5, 2026 22:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

Code Coverage (GCC + lcov)

Utils/MathUtils.cpp                            |    -     0|    -   0|    -    0
Utils/MemoryDebugger.h                         |13.3%   150| 0.0%  20|    -    0
Utils/MemoryMonitor.cpp                        | 9.6%   229| 0.0%  19|    -    0
Utils/MemoryMonitor.h                          |85.7%    14| 0.0%  12|    -    0
Utils/MultiISA.h                               |42.9%    14| 0.0%   6|    -    0
Utils/NetworkHealthMonitor.cpp                 | 113%    15| 0.0%   2|    -    0
Utils/NetworkHealthMonitor.h                   |    -     0|    -   0|    -    0
Utils/OpaqueHandle.h                           | 209%    11| 0.0%  15|    -    0
Utils/Profiler.cpp                             |14.2%   113| 0.0%  15|    -    0
Utils/Profiler.h                               |36.4%    33| 0.0%  12|    -    0
Utils/RandomEngine.h                           |29.3%    41| 0.0%  12|    -    0
Utils/Result.h                                 | 100%    29| 0.0%  28|    -    0
Utils/RingBuffer.h                             | 108%    59| 0.0%  64|    -    0
Utils/ScopeGuard.h                             | 142%    36| 0.0%  51|    -    0
Utils/ScopedTimer.h                            |25.0%    12| 0.0%   3|    -    0
Utils/Serializer.h                             | 100%    48| 0.0%  42|    -    0
Utils/SparkConsole.cpp                         |93.2%    44| 0.0%   7|    -    0
Utils/SparkConsole.h                           | 100%     2| 0.0%   2|    -    0
Utils/SparkError.h                             |10.9%    55| 0.0%   6|    -    0
Utils/SplinePath.h                             |    -     0|    -   0|    -    0
Utils/StackTrace.h                             |11.0%    73| 0.0%   8|    -    0
Utils/StateMachine.h                           |54.0%    63| 0.0%  32|    -    0
Utils/StringUtils.h                            |18.8%   112| 0.0%  21|    -    0
Utils/Telemetry.h                              |21.8%    87| 0.0%  16|    -    0
Utils/ThreadDebugger.h                         |12.8%   148| 0.0%  19|    -    0
Utils/ThreadSafeQueue.h                        |27.5%    40| 0.0%  11|    -    0
Utils/UUID.h                                   |43.2%    37| 0.0%  16|    -    0
Utils/Validate.h                               |    -     0|    -   0|    -    0

[/home/runner/work/SparkEngine/SparkEngine/SparkSDK/Include/Spark/]
IEngineContext.h                               |6700%     1| 0.0%   1|    -    0
Version.h                                      |    -     0|    -   0|    -    0
================================================================================
                                         Total:|31.3% 15823| 0.0%  2k|    -    0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants