Derive meta-power registry ids from the game types #309

Merged
nelsong6 merged 1 commit from claude/defect-buffer-damage-tracking-78608c into main 2026-08-08 17:10:31 -07:00
nelsong6 commented 2026-08-08 17:10:24 -07:00 (Migrated from github.com)

ModelDb.GetId slugifies the whole type name and only strips _MODEL from the category, so RupturePower is POWER.RUPTURE_POWER. Every hand-copied entry in MetaPowerRegistry used a shortened form the game never emits, and TryGetByPower matches on power.Id — so RecordMetaPowerApplicationLocked returned early for all 19 entries.

Measured impact

Across 434 saved runs (Apr 28 – Aug 8), successful_applications and meta_active_turns are zero in every one of the 30 power aggregates. Neither has ever recorded a value.

Card-driven paths (TryGetByCard, which worked because card ids have no suffix) kept writing denominators under the short key, while power.Id.ToString() paths wrote outcomes under the canonical key — splitting one power across two aggregates. One run holds Danse Macabre with block_gained: 56, turns_active: 7 under POWER.DANSE_MACABRE_POWER while the tooltip looked up POWER.DANSE_MACABRE and rendered 0.

OrbCardRegistry and RandomCardGenerationRegistry had the identical defect. OrbCardRegistry.TryGetRecurringByPower matches a live power id, so recurring-Power orb attribution was dead the same way.

The fix

All three registries resolve ids through ModelIds.TryGet<T>(), which asks the game. It returns null instead of throwing so one changed model hierarchy cannot take a registry down at class load, and the lists are lazy for the same reason. A renamed game class is now a compile error rather than a lookup that quietly returns nothing.

Tooltip meta-power switches dispatch on card ids: switch labels must be compile-time constants, derived power ids cannot be, and card ids carry no type suffix. That removes ten duplicated power-id consts.

Dead code removed

Nine Append*PowerStats helpers — Entropy, Juggling, Danse Macabre, Vicious, Dark Embrace, Stampede, Feel No Pain, Aggression, Rupture — had zero call sites in a non-partial class where they are private static. They were a second, also-broken rendering of rows the shared switch already produces, and the sole reason ten of the wrong-id consts existed. Their DisplayName fallbacks are why this looked partially mitigated; nothing was actually reachable.

No history reconciliation

Deliberate. The two stats that broke were never written to disk, so a merge could only recover one run''s block total — not worth new logic in the persistence path every run file passes through. Old files keep both key forms; the primer explains why.

Notes

  • MetaPowerRegistryTests now pins that every entry is POWER.*_POWER and that lookup by live id round-trips. ConsumingShadowPowerStatsTests had a hardcoded POWER.CONSUMING_SHADOW that was asserting the bug.
  • No new Harmony targets, so no restart is required for this change.
  • Tests not run, per the repo''s user-owned verification rule. Both projects compile clean.
`ModelDb.GetId` slugifies the whole type name and only strips `_MODEL` from the category, so `RupturePower` is `POWER.RUPTURE_POWER`. Every hand-copied entry in `MetaPowerRegistry` used a shortened form the game never emits, and `TryGetByPower` matches on `power.Id` — so `RecordMetaPowerApplicationLocked` returned early for all 19 entries. ## Measured impact Across 434 saved runs (Apr 28 – Aug 8), `successful_applications` and `meta_active_turns` are **zero in every one of the 30 power aggregates**. Neither has ever recorded a value. Card-driven paths (`TryGetByCard`, which worked because card ids have no suffix) kept writing denominators under the short key, while `power.Id.ToString()` paths wrote outcomes under the canonical key — splitting one power across two aggregates. One run holds Danse Macabre with `block_gained: 56, turns_active: 7` under `POWER.DANSE_MACABRE_POWER` while the tooltip looked up `POWER.DANSE_MACABRE` and rendered 0. `OrbCardRegistry` and `RandomCardGenerationRegistry` had the identical defect. `OrbCardRegistry.TryGetRecurringByPower` matches a live power id, so recurring-Power orb attribution was dead the same way. ## The fix All three registries resolve ids through `ModelIds.TryGet<T>()`, which asks the game. It returns null instead of throwing so one changed model hierarchy cannot take a registry down at class load, and the lists are lazy for the same reason. A renamed game class is now a compile error rather than a lookup that quietly returns nothing. Tooltip meta-power switches dispatch on **card** ids: switch labels must be compile-time constants, derived power ids cannot be, and card ids carry no type suffix. That removes ten duplicated power-id consts. ## Dead code removed Nine `Append*PowerStats` helpers — Entropy, Juggling, Danse Macabre, Vicious, Dark Embrace, Stampede, Feel No Pain, Aggression, Rupture — had zero call sites in a non-partial class where they are `private static`. They were a second, also-broken rendering of rows the shared switch already produces, and the sole reason ten of the wrong-id consts existed. Their `DisplayName` fallbacks are why this looked partially mitigated; nothing was actually reachable. ## No history reconciliation Deliberate. The two stats that broke were never written to disk, so a merge could only recover one run''s block total — not worth new logic in the persistence path every run file passes through. Old files keep both key forms; the primer explains why. ## Notes - `MetaPowerRegistryTests` now pins that every entry is `POWER.*_POWER` and that lookup by live id round-trips. `ConsumingShadowPowerStatsTests` had a hardcoded `POWER.CONSUMING_SHADOW` that was asserting the bug. - No new Harmony targets, so no restart is required for this change. - Tests not run, per the repo''s user-owned verification rule. Both projects compile clean.
Sign in to join this conversation.
No reviewers
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!309
No description provided.