Skip to content

Claude/refactor codebase iz ey h#490

Merged
Krilliac merged 3 commits into
Workingfrom
claude/refactor-codebase-IzEyH
Apr 17, 2026
Merged

Claude/refactor codebase iz ey h#490
Krilliac merged 3 commits into
Workingfrom
claude/refactor-codebase-IzEyH

Conversation

@Krilliac

Copy link
Copy Markdown
Owner

No description provided.

claude added 3 commits April 17, 2026 18:37
…untime

Replaces the 9 deprecated free-floating `g_graphics`/`g_input`/`g_timer`/
`g_eventBus`/`g_moduleManager`/`g_audioEngine`/`g_audioBackend`/
`g_moduleHotReload`/`g_physicsOwned` globals — previously defined in
SparkEngine.cpp and `extern`-declared in each platform entry file — with
a single `EngineRuntime` ownership struct accessed via `GetEngineRuntime()`.

Subsystem lookup for the rest of the engine continues to go through
EngineContext. External code never touched these globals (confirmed by
grep) — the migration is contained to Core/SparkEngine{,Windows,Linux}.cpp.

Net diff is ~zero lines (token swap); no behavioural change. Tests pass,
all 5869. Updates CLAUDE.md and .claude/knowledge/codebase-observations.md
to document the new access pattern.

https://claude.ai/code/session_015coEh2fxVdjJWj2NyWxR7t
D3D11, D3D12, Vulkan, and OpenGL backends all carried identical copies
of the same three members:
  - RHIDeviceCapabilities m_capabilities
  - RHIStatistics m_statistics
  - TransientBufferAllocator m_transientBuffers{4M, 2M}

…plus the identical inline GetCapabilities/GetStatistics getters and
a one-line `ResetStatistics() { m_statistics = {}; }` body. Those now
live on a new RHIDeviceBase that each concrete backend inherits from.
BeginFrame/EndFrame still own their backend-specific work (fence
pacing on D3D12, deletion queue on D3D11, etc.) and call through to
the inherited transient pump and ResetStatistics().

NullRHIDevice intentionally stays on IRHIDevice directly — it uses
different field names (m_caps / m_rhiStats) and a smaller transient
budget (64K/32K) for the headless fallback.

Net: -76 lines across the four backends, +51 lines for the new base.
Future RHI backends (Metal, WebGPU) now inherit this boilerplate for
free. Tests: all 5869 pass; build clean.

https://claude.ai/code/session_015coEh2fxVdjJWj2NyWxR7t
…torUI

EditorUI.cpp went from 1777 lines to 1515 by extracting two cohesive,
low-coupling slices:

1. **EditorCommandRegistry.cpp** (sibling-file pattern, mirrors
   EditorMenuBar.cpp). Holds the InitializeCommandPalette /
   RegisterPanelToggleCommands / RegisterEditCommands /
   RegisterSceneCommands / RegisterToolCommands methods — pure
   data-driven registration that only touches m_commandPalette and
   already-public state. No public-API change.

2. **EditorNotificationManager** (independent class). Owns the
   Notification struct, the m_notifications vector, and the
   Update()/Render()/Show() methods. EditorUI now holds a
   unique_ptr<EditorNotificationManager> and its ShowNotification()
   becomes a thin delegate. RenderNotifications() and
   UpdateNotifications() helpers are gone — Update/Render call the
   manager directly.

Net: -262 lines removed from EditorUI.cpp (-14.7%). Two new files
introduced; the new class is independently testable and the command
registry file keeps the same EditorUI class surface.

All 5869 tests pass; build clean.

https://claude.ai/code/session_015coEh2fxVdjJWj2NyWxR7t
@Krilliac
Krilliac merged commit f6f134f into Working Apr 17, 2026
31 of 41 checks passed
@Krilliac
Krilliac deleted the claude/refactor-codebase-IzEyH branch April 17, 2026 19:40
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage (GCC + lcov)

Utils/Result.h                                 | 100%    29| 0.0%  28|    -    0
Utils/RingBuffer.h                             | 142%    59| 0.0%  84|    -    0
Utils/ScheduledCallback.h                      |    -     0|    -   0|    -    0
Utils/ScopeGuard.h                             | 142%    36| 0.0%  51|    -    0
Utils/ScopedTimer.h                            |25.0%    12| 0.0%   3|    -    0
Utils/Serializer.h                             |86.2%    58| 0.0%  44|    -    0
Utils/ShaderServiceClient.cpp                  |12.2%    41| 0.0%   4|    -    0
Utils/ShaderServiceClient.h                    | 100%     1| 0.0%   1|    -    0
Utils/ShaderServiceProtocol.h                  |11.8%    68| 0.0%   8|    -    0
Utils/SparkConsole.cpp                         |27.2%   151| 0.0%  18|    -    0
Utils/SparkConsole.h                           | 100%     2| 0.0%   2|    -    0
Utils/SparkError.h                             |10.9%    55| 0.0%   6|    -    0
Utils/SplineMath.cpp                           |20.5%    39| 0.0%   5|    -    0
Utils/SplinePath.h                             |    -     0|    -   0|    -    0
Utils/StackTrace.h                             |10.8%    74| 0.0%   8|    -    0
Utils/StateMachine.h                           |85.9%    64| 0.0%  49|    -    0
Utils/StringUtils.h                            |18.1%   116| 0.0%  21|    -    0
Utils/Telemetry.h                              |20.6%   136| 0.0%  23|    -    0
Utils/ThreadDebugger.h                         |11.6%   199| 0.0%  23|    -    0
Utils/ThreadSafeQueue.h                        |27.5%    40| 0.0%  11|    -    0
Utils/Timer.cpp                                |19.4%    36| 0.0%   7|    -    0
Utils/Timer.h                                  | 100%     2| 0.0%   2|    -    0
Utils/TimerManager.h                           |18.6%   102| 0.0%  19|    -    0
Utils/Tween.h                                  |26.3%    38| 0.0%   6|    -    0
Utils/UUID.h                                   |43.2%    37| 0.0%  16|    -    0
Utils/Validate.h                               |    -     0|    -   0|    -    0
Utils/WineDetection.cpp                        |23.1%    39| 0.0%   9|    -    0

[/home/runner/work/SparkEngine/SparkEngine/SparkSDK/Include/Spark/]
IEngineContext.h                               |7300%     1| 0.0%   1|    -    0
ServiceInterfaces.h                            | 200%     3| 0.0%   3|    -    0
Version.h                                      |    -     0|    -   0|    -    0
================================================================================
                                         Total:|31.0% 34128| 0.0%  6k|    -    0

Per-Subsystem Coverage

Subsystem Lines Hit Coverage Threshold Status
AI 3716 942 25.3% 35%
Animation 905 277 30.6% 35%
Audio 0 0 0% 30%
Camera 0 0 0% 40%
Core 4882 2918 59.8% 40%
ECS 426 213 50% 40%
Editor 7411 3046 41.1% 25%
GameModules 6621 3230 48.8% 30%
Graphics 17002 8336 49% 30%
Networking 3554 2351 66.2% 35%
Physics 0 0 0% 35%
Scripting 283 80 28.3% 30%
Utils 9778 6050 61.9% 60%

Total: 50.3% (27443/54578 lines)

@github-actions

Copy link
Copy Markdown
Contributor

❌ CI Error Report

Failed jobs: check-format, clang-tidy, linux-clang-Release, macos-Debug, macos-Release, windows-vs2022-Release
Errors: 3 | Test failures: 4 | Test warnings: 15 | Compiler warnings: 6

Build Errors

File Line Error Jobs
SparkEngine/Source/Utils/Expected.h 40 code should be clang-formatted [-Wclang-format-violations] check-format
Other errors (2)
clang++: error: linker command failed with exit code 1 (use -v to see invocation) [linux-clang-Release]
clang++: error: linker command failed with exit code 1 (u e -v to  ee invocation) [macos-Debug, macos-Release]
Full error output
SparkEngine/Source/Utils/Expected.h:40:31: error: code should be clang-formatted [-Wclang-format-violations]
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
clang++: error: linker command failed with exit code 1 (u e -v to  ee invocation)
### Test Failures
Test Jobs
1/1 Test #1: SparkEngineTests .................***Failed 14.29 sec windows-vs2022-Release
[ FAILED ] NetworkStack_UDPInitializeSucceeds (59us, 3 assertions) windows-vs2022-Release
::warning title=Flaky test: Integration_NetworkingECS_ReplicationLatencyJitterPredictionReconciliation::Integration_N... windows-vs2022-Release
0% tests passed, 1 tests failed out of 1 windows-vs2022-Release

⚠️ Test Warnings (Known Flaky)

These tests are registered as known flaky and do not block the build:

Test Jobs
[20:30:12.025] [TID:7364] [WARN ] [Network ] RCON unknown command: nonexistent_cmd (DedicatedServer.cpp:573) windows-vs2022-Release
[20:30:12.040] [TID:7364] [WARN ] [Network ] NetBuffer::ReadUint8 — buffer overrun at pos 1 (size=1) (NetworkBuffer.c... windows-vs2022-Release
[20:30:12.060] [TID:7364] [WARN ] [AI ] BuildNavMeshWithRecast: empty geometry (RecastDetourBackend.cpp:35) windows-vs2022-Release
[20:30:12.060] [TID:7364] [WARN ] [AI ] NavMeshBuilder: Recast build failed, falling back to triangle-soup builder (N... windows-vs2022-Release
[20:30:12.060] [TID:7364] [WARN ] [Audio ] XAudio2 backend requested but no AudioEngine provided, falling back to Nul... windows-vs2022-Release
[20:30:12.061] [TID:7364] [WARN ] [Audio ] XAudio2 backend requested but no AudioEngine provided, falling back to Nul... windows-vs2022-Release
[ [20:30:12.062] [TID:7364] [WARN ] [Graphics ] No graphics backend available — falling back to NullRHIDevice (headle... windows-vs2022-Release
[20:30:12.062] [TID:7364] [WARN ] [Graphics ] No graphics backend available — falling back to NullRHIDevice (headless... windows-vs2022-Release
[20:30:12.067] [TID:7364] [WARN ] [Editor ] Cannot host: userName is empty. (CollaborativeEditSession.cpp:454) windows-vs2022-Release
[20:30:12.067] [TID:7364] [WARN ] [Editor ] Already connected. (CollaborativeEditSession.cpp:459) windows-vs2022-Release
[20:30:12.069] [TID:7364] [WARN ] [Editor ] BroadcastEdit rejected: nodeId is empty. (CollaborativeEditSession.cpp:1108) windows-vs2022-Release
[20:30:12.069] [TID:7364] [WARN ] [Editor ] BroadcastEdit rejected: sourceEditor is not set. (CollaborativeEditSessio... windows-vs2022-Release
[20:30:12.070] [TID:7364] [WARN ] [Editor ] SetLocalSelection rejected: nodeId exceeds 255 chars (length=300). (Colla... windows-vs2022-Release
[20:30:17.649] [TID:7364] [WARN ] [Network ] Connection rejected for pending client 5: server full (4/4) (NetworkConn... windows-vs2022-Release
[20:30:17.650] [TID:7364] [WARN ] [Network ] Connection rejected for pending client 5: server full (4/4) (NetworkConn... windows-vs2022-Release
Compiler Warnings (6)
../../../ThirdParty/SDL2/src/joystick/hidapi/SDL_hidapi_steam.c:165:9: warning: 'printf' macro redefined [-Wmacro-redefined] [linux-clang-Release]
../SparkEngine/Source/Engine/Animation/BlendSpace.cpp:313:16: warning: variable 'validTriCount' set but not used [-Wunused-but-set-variable] [linux-clang-Release]
../SparkEngine/Source/Physics/PhysicsBodyImpl.cpp:270:23: warning: comparing floating point with == or != is unsafe [-Wfloat-equal] [linux-clang-Release]
../SparkEngine/Source/Physics/PhysicsSystem.cpp:401:12: warning: use of old-style cast [-Wold-style-cast] [linux-clang-Release]
../../Tests/TestReliableChannel.cpp:390:9: warning: variable 'retransmitCount' set but not used [-Wunused-but-set-variable] [linux-clang-Release]
../../Tests/TestSparkError.cpp:34:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result] [linux-clang-Release]

Updated: 2026-04-17T20:30:51Z — this comment is updated in-place, not duplicated.

Krilliac pushed a commit that referenced this pull request Apr 18, 2026
build-linux-clang (Release) has been failing with:
  /usr/bin/ld: ../lib/libJolt.a: error adding symbols: file format not recognized
  clang++: error: linker command failed with exit code 1

Root cause: actions/cache restores a build/ directory from a previous
run. When apt-get upgrades clang / binutils between runs, the cached
libJolt.a can end up in a format the current linker no longer
recognizes — similar to the existing PCH-vs-unistd_64.h mtime mismatch
that this job already handles.

Extend the existing stale-artifact cleanup to also scan lib*.a
archives. Each one is probed with \`ar t\`; any archive that can't be
listed is purged, forcing CMake to rebuild it on the next step.
ccache still keeps .o compilation fast.

Pre-existing failure (also hit PR #490 on the same job); fixed here.
Krilliac pushed a commit that referenced this pull request Apr 18, 2026
Two pre-existing failures that were already present on PR #490 / Working:

1. NetworkStack_UDPInitializeSucceeds on Windows
   `UDPTransport::Initialize()` called ::socket() without calling
   WSAStartup() — on Windows that fails with WSANOTINITIALISED. The
   only call to WSAStartup() lived inside `NetworkManager::Initialize()`,
   so any test or subsystem creating a bare NetworkStack / UDPTransport
   couldn't open a socket.

   Fix: add a reference-counted `WinsockScope` RAII helper inside
   UDPTransport.h (Windows-only). Each UDPTransport takes one reference
   in Initialize() and releases it in Shutdown(); the first scope calls
   WSAStartup, the last calls WSACleanup.

2. build-macos (Debug/Release) — same `libJolt.a: error adding symbols:
   file format not recognized` as linux-clang. apt-get / brew upgrades
   leave stale archives in actions/cache, which the current ld can't
   parse. Extended the build step with the same `ar t`-based probe +
   rm that we just added to linux-clang.

Local: 5616/5616 tests pass, including the now-portable
NetworkStack_UDPInitializeSucceeds.
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