[P2] Codebase hygiene sweep: diagnostics, UI/tooltip, loader/config, tests, MP, harness literals #257

Closed
opened 2026-07-03 02:30:55 -07:00 by nelsong6 · 2 comments
nelsong6 commented 2026-07-03 02:30:55 -07:00 (Migrated from github.com)

Priority: P2. From the 2026-07-02 audit. A consolidated hygiene sweep grouping lower-severity, mostly-unverified findings. Split into sub-PRs as convenient.

Diagnostics / dead code

  • RunTracker.Observe carries a self-described "temporary diagnostic for draw-tracking bug" that is now permanent always-on Logger.Info: every CardDrawnEntry/CardPlayFinishedEntry, the first 500 entries per load, an every-50th joined type-count dump, plus a second per-draw log. Gate behind DebugLogging or delete. The backing _typeCountDiag dict is also the only RunTracker static mutated without _lock.
  • The [CUS-diag] Harmony dump prints 60–80 Info lines per launch/reload from the global registry (so it can't even confirm SpireLens-installed hooks). Now partly superseded by the Patch install: summary line added in PR #248.
  • Loader diag log (%TEMP%\spirelens-loader-diag.log) and its D() channel grow unbounded — add rotation/truncation.

UI / tooltip robustness

  • All four view-stats gates read a static tickbox reference never cleared when the deck view frees the node, so the toggle short-circuits on a stale boolean and the config/MCP fallback is dead (CardHoverTooltipPatch.cs:54 + Relic/Enemy/DeckViewInjectRemoved). Guard with GodotObject.IsInstanceValid, drop the _prefsLoaded one-shot, call RuntimeOptionsProvider.Refresh().
  • Game-provided display names are interpolated unescaped into RichTextLabel BBCode across many rows — a card named [b] breaks rendering. Escape them.
  • Node/handler leaks: _injectedClones accumulates dead wrappers; StatsTooltip rebuild leaks per-frame handlers. Relic tooltip is ~200 lines of drifting near-identical if-blocks with triplicated Row3/FormatDecimal helpers — consolidate.

Loader / config / build hygiene

  • EnableDebugLogging captured once at Initialize, so the tickbox is inert until an F5 reload (CoreMain.cs:80).
  • Legacy-prefs migration reads the wrong path (user://SpireLens vs the actual user://CardUtilityStats) so it never finds anything.
  • API generation resolution can serve a stale orphaned Core; BuildInfo is compiled only into the never-reloaded Loader (describes the launch loader, not the running Core); LoaderMain load-contract docs no longer match the code (claims per-load ALC but uses the shared Godot ALC).

Test-suite fidelity

  • ~25 test files hand-copy RunStorage.Options (snake_case + WhenWritingNull) — the same parallel-list pattern that produced the Activations bug; expose RunStorage.Options (internal) and consume it in tests.
  • ~12 test classes bind private members by string reflection despite InternalsVisibleTo; NoxiousFumesContributionTests uses GetProperty(...)?.SetValue so a rename silently skips setup. Use direct member access.
  • ~15 tooltip test files assert labels and values as independent substrings, so values aren't bound to rows and duplicate values make transposition bugs unfalsifiable. Add a helper asserting label-and-value on the same row.
  • The 11 asset-coupled tooltip-icon tests fail when built against the checked-in lib/ stub (they need the live game DLL) — decouple them or mark them as requiring the live game.

Multiplayer/co-op ownership

  • Zero patches distinguish the local player from co-op partners; the player block ledger and armed-clear are singletons fed by both players, garbaging block stats in any MP combat. Decision needed: either key ledgers/windows per Player with an ownership gate at each entry point, or explicitly gate tracking off when Players.Count > 1 and document MP as out of scope. Pick one and apply uniformly.

Harness hardcoded literals

  • D:\repos\SpireLens appears ~4× with casing drift across helpers.go / host.go / buildanddeploy.go; bridge port 15526 has no env override; claude.exe/Steam/mcp paths are frozen. De-hardcode behind config/env.

Small stat-hygiene items

Four recorded-but-never-displayed aggregate fields; RecordPowerReceived missing an amount > 0 guard (emits zero/negative TimesApplied); EnemyStatusCardSource AsyncLocal frame can restore null over a live frame; _pendingMakeItSoSummons marker consumed by the first pile change; FindCurrentlyResolvingCardPlay does an O(n) LINQ Reverse per event; README lists closed issue #10 as Open.

**Priority: P2.** From the 2026-07-02 audit. A consolidated hygiene sweep grouping lower-severity, mostly-unverified findings. Split into sub-PRs as convenient. ## Diagnostics / dead code - `RunTracker.Observe` carries a self-described "temporary diagnostic for draw-tracking bug" that is now **permanent always-on `Logger.Info`**: every `CardDrawnEntry`/`CardPlayFinishedEntry`, the first 500 entries per load, an every-50th joined type-count dump, plus a second per-draw log. Gate behind `DebugLogging` or delete. The backing `_typeCountDiag` dict is also the only `RunTracker` static mutated **without `_lock`**. - The `[CUS-diag]` Harmony dump prints 60–80 `Info` lines per launch/reload from the **global** registry (so it can't even confirm SpireLens-installed hooks). Now partly superseded by the `Patch install:` summary line added in PR #248. - Loader diag log (`%TEMP%\spirelens-loader-diag.log`) and its `D()` channel grow unbounded — add rotation/truncation. ## UI / tooltip robustness - All four view-stats gates read a static tickbox reference never cleared when the deck view frees the node, so the toggle short-circuits on a stale boolean and the config/MCP fallback is dead (`CardHoverTooltipPatch.cs:54` + Relic/Enemy/DeckViewInjectRemoved). Guard with `GodotObject.IsInstanceValid`, drop the `_prefsLoaded` one-shot, call `RuntimeOptionsProvider.Refresh()`. - Game-provided display names are interpolated **unescaped** into RichTextLabel BBCode across many rows — a card named `[b]` breaks rendering. Escape them. - Node/handler leaks: `_injectedClones` accumulates dead wrappers; StatsTooltip rebuild leaks per-frame handlers. Relic tooltip is ~200 lines of drifting near-identical if-blocks with triplicated `Row3`/`FormatDecimal` helpers — consolidate. ## Loader / config / build hygiene - `EnableDebugLogging` captured once at `Initialize`, so the tickbox is inert until an F5 reload (`CoreMain.cs:80`). - Legacy-prefs migration reads the wrong path (`user://SpireLens` vs the actual `user://CardUtilityStats`) so it never finds anything. - API generation resolution can serve a stale orphaned Core; `BuildInfo` is compiled only into the never-reloaded Loader (describes the launch loader, not the running Core); LoaderMain load-contract docs no longer match the code (claims per-load ALC but uses the shared Godot ALC). ## Test-suite fidelity - ~25 test files hand-copy `RunStorage.Options` (snake_case + `WhenWritingNull`) — the same parallel-list pattern that produced the `Activations` bug; expose `RunStorage.Options` (internal) and consume it in tests. - ~12 test classes bind private members by string reflection despite `InternalsVisibleTo`; `NoxiousFumesContributionTests` uses `GetProperty(...)?.SetValue` so a rename silently skips setup. Use direct member access. - ~15 tooltip test files assert labels and values as independent substrings, so values aren't bound to rows and duplicate values make transposition bugs unfalsifiable. Add a helper asserting label-and-value on the same row. - The 11 asset-coupled tooltip-icon tests fail when built against the checked-in `lib/` stub (they need the live game DLL) — decouple them or mark them as requiring the live game. ## Multiplayer/co-op ownership - Zero patches distinguish the local player from co-op partners; the player block ledger and armed-clear are singletons fed by both players, garbaging block stats in any MP combat. **Decision needed:** either key ledgers/windows per `Player` with an ownership gate at each entry point, or explicitly gate tracking off when `Players.Count > 1` and document MP as out of scope. Pick one and apply uniformly. ## Harness hardcoded literals - `D:\repos\SpireLens` appears ~4× with casing drift across `helpers.go` / `host.go` / `buildanddeploy.go`; bridge port `15526` has no env override; `claude.exe`/Steam/mcp paths are frozen. De-hardcode behind config/env. ## Small stat-hygiene items Four recorded-but-never-displayed aggregate fields; `RecordPowerReceived` missing an `amount > 0` guard (emits zero/negative `TimesApplied`); `EnemyStatusCardSource` AsyncLocal frame can restore null over a live frame; `_pendingMakeItSoSummons` marker consumed by the first pile change; `FindCurrentlyResolvingCardPlay` does an O(n) LINQ `Reverse` per event; README lists closed issue #10 as Open.
nelsong6 commented 2026-07-03 09:34:29 -07:00 (Migrated from github.com)

Uncapped audit pass — two items here should be PROMOTED to P1 (confirmed HIGH, not hygiene):

  • View-stats toggle stuck on a freed-node reference (#74): all four view-stats gates prioritize ViewStatsInjectorPatch.LastInjectedTickbox?.IsTicked, but the node is freed when the deck view closes and the static is never cleared; NTickbox.IsTicked returns a stale false instead of throwing, so set_spirelens_view_stats_enabled(true) and the settings toggle silently no-op for the rest of the Core lifetime. Guard with GodotObject.IsInstanceValid, call RuntimeOptionsProvider.Refresh() before each read, drop the _prefsLoaded one-shot.
  • Multiplayer ownership has been split out to its own P1 issue (zero LocalContext usage → co-op stat corruption). Remove it from this hygiene bucket.
**Uncapped audit pass — two items here should be PROMOTED to P1 (confirmed HIGH, not hygiene):** - **View-stats toggle stuck on a freed-node reference (#74):** all four view-stats gates prioritize `ViewStatsInjectorPatch.LastInjectedTickbox?.IsTicked`, but the node is freed when the deck view closes and the static is never cleared; `NTickbox.IsTicked` returns a stale `false` instead of throwing, so `set_spirelens_view_stats_enabled(true)` and the settings toggle silently no-op for the rest of the Core lifetime. Guard with `GodotObject.IsInstanceValid`, call `RuntimeOptionsProvider.Refresh()` before each read, drop the `_prefsLoaded` one-shot. - **Multiplayer ownership** has been split out to its own P1 issue (zero `LocalContext` usage → co-op stat corruption). Remove it from this hygiene bucket.
nelsong6 commented 2026-07-05 15:45:04 -07:00 (Migrated from github.com)

Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.

Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens#257
No description provided.