From e472c2e0f1fae4964003a5484c8b1e6b1cf50639 Mon Sep 17 00:00:00 2001 From: Danielle Date: Wed, 10 Jun 2026 20:23:52 +1000 Subject: [PATCH 1/7] Codebase audit: fix 44 verified bugs, races and hot-path allocations (v4.2.73 -> v4.3.1) Multi-agent audit of the full codebase (67 raw findings, adversarially verified down to 47; 3 build-script credential items handled separately by the owner). Fixes by area: Core: lock discipline for _runningEffects and _activeDevices, _layergroups swapped to ConcurrentDictionary (game loop vs RGB.NET timer thread race), dead CPU-throttle branch removed, Sentry heartbeat no longer blocks a thread-pool thread. Layers: DamageFlash min-opacity clamp inverted the whole (0,1) range, JobGaugeA/B/C interpolate mode rebuilt LED groups every tick, missing _disposed guard in TargetCastbar, per-tick brush and dictionary allocations hoisted across nine processors, CutsceneAnimation dead decorator allocation removed, GetLedArray O(n*m) scan now a HashSet. Decorators: ArenaLightShow blended a 0-1 base color into a 0-255 scale (base color invisible), Strobe/Pulse detach race guards, RectangularGradient bottom-edge interpolation typo. Devices: Yeelight dedup state no longer poisoned by failed sends (bulb recovers after Wi-Fi drops, errors surface once per outage), Music Mode accept task leak fixed, LIFX and QMK inter-chunk sleeps moved outside the device lock (UI no longer freezes on multizone re-enable), per-frame buffer allocations removed in DynamicLighting, Alienware, EVision, Redragon and QMK queues. Helpers: settings deserialization NRE in DictionaryConverter, Blacksmith job used Black Mage palette colors, palette/effects/settings saves now atomic (tmp + replace), GetMaxCpuUsage read a memory counter. UI: Hue adoption dialog mutated ObservableCollection off the UI thread, LocalizationService subscription leaks in layer items and adoption dialogs, console trim no longer fires 500 list shifts, registry key in SettingsViewModel now scoped and disposed. Harness: SavePreset now round-trips all 28 effect parameters. Build clean, 133/133 tests pass. Co-Authored-By: Claude Fable 5 --- .../MainViewModel.cs | 24 ++ Chromatics/Chromatics.csproj | 4 +- Chromatics/Core/GameController.cs | 21 +- Chromatics/Core/RGBController.cs | 116 ++++++---- Chromatics/Core/SentryService.cs | 218 +++++++++--------- .../Decorators/ArenaLightShowDecorator.cs | 6 +- .../RGB.NET/Decorators/PulseDecorator.cs | 10 +- .../RGB.NET/Decorators/StrobeDecorator.cs | 212 +++++++++-------- .../Devices/Alienware/AlienwareUpdateQueue.cs | 42 ++-- .../DynamicLightingUpdateQueue.cs | 17 +- .../Devices/EVision/EVisionUpdateQueue.cs | 10 +- .../RGB.NET/Devices/LIFX/LifxUpdateQueue.cs | 80 +++++-- .../Devices/QmkRawHid/QmkRawHidUpdateQueue.cs | 94 ++++++-- .../Devices/Redragon/RedragonUpdateQueue.cs | 17 +- .../Yeelight/Protocol/YeelightConnection.cs | 8 +- .../Devices/Yeelight/YeelightUpdateQueue.cs | 90 +++++++- .../RGB.NET/Gradients/RectangularGradient.cs | 2 +- Chromatics/Helpers/DictionaryConverter.cs | 2 +- Chromatics/Helpers/FileOperationsHelper.cs | 42 +--- Chromatics/Helpers/GameHelper.cs | 4 +- Chromatics/Helpers/SystemMonitorHelper.cs | 6 +- .../Layers/BaseLayers/AudioVisualizer.cs | 2 +- Chromatics/Layers/BaseLayers/BattleStance.cs | 14 +- Chromatics/Layers/BaseLayers/JobClasses.cs | 14 +- .../Layers/BaseLayers/ReactiveWeather.cs | 2 +- Chromatics/Layers/BaseLayers/ScreenCapture.cs | 2 +- Chromatics/Layers/BaseLayers/Static.cs | 2 +- .../Layers/DynamicLayers/BattleStance.cs | 15 +- Chromatics/Layers/DynamicLayers/Castbar.cs | 2 +- .../Layers/DynamicLayers/EnmityTracker.cs | 2 +- .../Layers/DynamicLayers/ExperienceTracker.cs | 2 +- Chromatics/Layers/DynamicLayers/HPTracker.cs | 2 +- Chromatics/Layers/DynamicLayers/Highlight.cs | 14 +- .../DynamicLayers/JobClassesHighlight.cs | 14 +- Chromatics/Layers/DynamicLayers/JobGaugeA.cs | 34 +-- Chromatics/Layers/DynamicLayers/JobGaugeB.cs | 34 +-- Chromatics/Layers/DynamicLayers/JobGaugeC.cs | 33 +-- Chromatics/Layers/DynamicLayers/Keybinds.cs | 48 ++-- Chromatics/Layers/DynamicLayers/MPTracker.cs | 2 +- .../DynamicLayers/ReactiveWeatherHighlight.cs | 2 +- .../Layers/DynamicLayers/TargetCastbar.cs | 13 +- Chromatics/Layers/DynamicLayers/TargetHP.cs | 2 +- .../Layers/EffectLayers/CutsceneAnimation.cs | 3 +- Chromatics/Layers/EffectLayers/DamageFlash.cs | 43 ++-- .../Layers/EffectLayers/DutyFinderBell.cs | 2 +- Chromatics/Layers/LayerProcessor.cs | 6 +- Chromatics/ViewModels/ConsoleViewModel.cs | 11 +- .../ViewModels/HueAdoptionDialogViewModel.cs | 11 +- .../ViewModels/LifxAdoptionDialogViewModel.cs | 7 +- .../ViewModels/Mapping/LayerItemViewModel.cs | 7 +- .../ViewModels/Mapping/MappingViewModel.cs | 3 + Chromatics/ViewModels/SettingsViewModel.cs | 7 +- .../YeelightAdoptionDialogViewModel.cs | 7 +- Chromatics/Views/HueAdoptionDialog.axaml.cs | 1 + Chromatics/Views/LifxAdoptionDialog.axaml.cs | 1 + .../Views/YeelightAdoptionDialog.axaml.cs | 1 + 56 files changed, 855 insertions(+), 535 deletions(-) diff --git a/Chromatics.DecoratorHarnessUI/MainViewModel.cs b/Chromatics.DecoratorHarnessUI/MainViewModel.cs index 817d61da..fe7c4f8e 100644 --- a/Chromatics.DecoratorHarnessUI/MainViewModel.cs +++ b/Chromatics.DecoratorHarnessUI/MainViewModel.cs @@ -739,6 +739,18 @@ private void ApplyDefaults(EffectEntry effect) ParamWaveSpeed = snap.WaveSpeed; ParamWaveFreq = snap.WaveFreq; ParamFadeTime = snap.FadeTime; ParamGroupSize = snap.GroupSize; ParamBlockSize = snap.BlockSize; ParamBlocks = snap.Blocks; ParamSize = snap.Size; + ParamNumberOfLeds = snap.NumberOfLeds; ParamStepSpeed = snap.StepSpeed; + ParamSustain = snap.Sustain; ParamRelease = snap.Release; ParamRepetitions = snap.Repetitions; + ParamDirection = snap.Direction; ParamRandomise = snap.Randomise; + ParamTextureType = snap.TextureType; ParamDiagonalDir = snap.DiagonalDir; ParamFallDir = snap.FallDir; + ParamIntensity = snap.Intensity; ParamFlickerSpeed = snap.FlickerSpeed; + ParamBeamWidth = snap.BeamWidth; ParamPulseRadius = snap.PulseRadius; ParamFadeWidth = snap.FadeWidth; + ParamTailLength = snap.TailLength; ParamSpawnInterval = snap.SpawnInterval; + ParamRippleSpeed = snap.RippleSpeed; ParamLaserDir = snap.LaserDir; + ParamBpmSpeed = snap.BpmSpeed; ParamBeatsPerCycle = snap.BeatsPerCycle; + ParamSimultaneousBeams = snap.SimultaneousBeams; ParamFlickerOpacity = snap.FlickerOpacity; + ParamMatrixDir = snap.MatrixDir; ParamFadeBetween = snap.FadeBetween; + ParamAccentEvery = snap.AccentEvery; ParamDecay = snap.Decay; ParamWedgeDegrees = snap.WedgeDegrees; ColorBase = snap.Base; SetColors(snap.Colors); return; @@ -1259,6 +1271,12 @@ private void SavePreset() ParamBpm, ParamSpeed, ParamInterval, ParamFadeSpeed, ParamDensity, ParamWaveSpeed, ParamWaveFreq, ParamFadeTime, ParamGroupSize, ParamBlockSize, ParamBlocks, ParamSize, + ParamNumberOfLeds, ParamStepSpeed, ParamSustain, ParamRelease, ParamRepetitions, + ParamDirection, ParamRandomise, ParamTextureType, ParamDiagonalDir, ParamFallDir, + ParamIntensity, ParamFlickerSpeed, ParamBeamWidth, ParamPulseRadius, ParamFadeWidth, + ParamTailLength, ParamSpawnInterval, ParamRippleSpeed, ParamLaserDir, + ParamBpmSpeed, ParamBeatsPerCycle, ParamSimultaneousBeams, ParamFlickerOpacity, + ParamMatrixDir, ParamFadeBetween, ParamAccentEvery, ParamDecay, ParamWedgeDegrees, ColorBase, ColorSlots.Select(s => s.Color).ToArray()); _savedParams[name] = snap; @@ -1273,6 +1291,12 @@ private record SavedParams( int Bpm, int Speed, double Interval, double FadeSpeed, double Density, double WaveSpeed, double WaveFreq, double FadeTime, int GroupSize, int BlockSize, int Blocks, int Size, + int NumberOfLeds, int StepSpeed, double Sustain, double Release, int Repetitions, + bool Direction, bool Randomise, string TextureType, string DiagonalDir, string FallDir, + double Intensity, double FlickerSpeed, double BeamWidth, double PulseRadius, double FadeWidth, + double TailLength, double SpawnInterval, double RippleSpeed, string LaserDir, + string BpmSpeed, double BeatsPerCycle, int SimultaneousBeams, double FlickerOpacity, + string MatrixDir, double FadeBetween, int AccentEvery, double Decay, double WedgeDegrees, AvColor Base, AvColor[] Colors); // ── Code snippet generator ────────────────────────────────────────── diff --git a/Chromatics/Chromatics.csproj b/Chromatics/Chromatics.csproj index 5b42a532..df556b9c 100644 --- a/Chromatics/Chromatics.csproj +++ b/Chromatics/Chromatics.csproj @@ -1,4 +1,4 @@ - + WinExe @@ -10,7 +10,7 @@ net10.0-windows10.0.19041.0 10.0.17763.0 Chromatics.Program - 4.2.73.0 + 4.3.1.0 Danielle Thompson