[P1] Eliminate hand-maintained aggregate field lists + add a reflection-exhaustive drift test #251
Labels
No labels
4-29
bug
documentation
duplicate
enhancement
flow improvement
good first issue
help wanted
invalid
investigating
issue-agent
issue-agent-blocked
issue-agent-complete
issue-agent-pr-open
issue-agent-runner-nelsonlaptop
issue-agent-runner-nelsonpc
issue-agent-runner-nelsonpc-user
issue-agent-running
needs-verification
next to do
question
queue
recon
relics-stats-onboarding
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/spirelens#251
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Priority: P1. From the 2026-07-02 audit. This is the exact shape of the already-fixed doubled-
Activationsbug (commitf859cda/ the relic merge consolidation) — fixed once as an instance, but the class keeps recurring.Problem
Aggregate stats are merged/cloned/pooled through several hand-maintained parallel field lists that silently drift:
GetRelicAggregate's ~26-field clone block duplicatesMergeRelicAggregateInto(whose own comment says "add fields HERE, once").CloneEnemyAggregateduplicatesMergeEnemyAggregateInto.CardAggregatePooler.MergeIntoomitsCombatsInDeckvsRunTracker.MergeAggregateInto.CloneAggregate/MergeAggregateInto/ pooler are four parallel lists;MergeAggregateIntosilently omits several lineage fields, andCloneAggregatecopiesRemovedSnapshotby reference.Consequence: a stat that lives only in an omitted field is dropped on merge/clone/pool; a field added twice is double-counted. For a stats tool these are "wrong numbers that look plausible and evade the current tests" — the most dangerous kind.
Fix
new X(); MergeXInto(result, source);(derive clone from the one merge function).CardAggregatePoolerdelegate to the canonical merge.Guardrail (the real fix)
A reflection-exhaustive test over every settable property of
CardAggregate/RelicAggregate/EnemyAggregate/AppliedEffectAggregate: populate each property with a distinct value and assertJSON(clone) == JSON(source),merge-into-empty == source, and additivity (merge(a,b)sums numerics). Any newly-added-but-unmerged field then fails the day it is added — covering all future fields for free.Uncapped audit pass — the RELIC/ENEMY inline clones are still live (verified), fold into this issue:
GetRelicAggregate(RunTracker.cs:3136-3163) hand-copies 26 RelicAggregate fields parallel toMergeRelicAggregateIntowhose own comment says 'add fields HERE, once' (#0, #144).CloneEnemyAggregate(~3258) duplicatesMergeEnemyAggregateInto(#23).CardAggregatePooler.MergeIntoomitsCombatsInDeckand duplicates 3 dict-merge helpers verbatim (#1, #2, #42, #77, #105).PendingCombatPromotionTests.Addressed in #264: the three parallel aggregate clone lists were collapsed onto the canonical Merge*Into functions (CloneAggregate keeps only lineage fields; CloneEnemyAggregate and the 26-field inline RelicAggregate clone became new+Merge), and AggregateDriftTests reflection-exhaustively asserts Clone(src)==src and Merge(new,src)==src — catching omission AND double-add. CardAggregatePooler.MergeInto delegation (#1) and the tautological POCO tests (#113) remain.
Closing during repository issue cleanup. If this becomes active work again, we can reopen or recreate it as a fresh, specific task.