Gate 1: give the resolver a Forget(owner); correct the recompute-cost comment
StatResolver's _cache, _modifiers and _generations were keyed by owner and nothing ever removed an entry, contradicting Sec 0b's promise that a resolver entry is "destroyed at unequip / entity teardown." A ConsumableItemEffect that expired still had a generations entry, and an unequipped EquippedItem's entries lived on for the rest of the process -- the same shape of leak the catalog object had before Cut 2, one level down. Forget(owner) drops every entry for that owner across all three dictionaries; Entity.TryUnequip and the consumable-expiry branch in Entity.Update now call it. Also adds GenerationOwnerCount/CacheEntryCount/ModifierEntryCount, a test-only surface a mutation test pins the retained-set claim against. F3: InvalidateSource's comment claimed a stat "recomputes only when a term's source changes." Entity.cs's UpdatePerformance calls it unconditionally every tick for Heat and Durability, regardless of whether the value moved, so the true invariant is "at most once per tick per (item, stat)." Corrected, and noted Quality as the one source this scheme still meaningfully defends against a real no-op tick (see F6 in ItemData.cs). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
dbb8be39d9
commit
b0d3354357
2 changed files with 51 additions and 4 deletions
|
|
@ -620,6 +620,11 @@ public abstract class Entity
|
|||
Sensor = null;
|
||||
}
|
||||
|
||||
// Cut 2 Gate 1 fix (docs/stats-and-power-cut.md): the resolver's §0b lifecycle promise -- a resolver
|
||||
// entry is "destroyed at unequip" -- was never wired up. Without this, every unequipped item stayed
|
||||
// reachable from the resolver's dictionaries for the entity's whole remaining life.
|
||||
Resolver.Forget(item);
|
||||
|
||||
return item.EquippableItem;
|
||||
}
|
||||
|
||||
|
|
@ -1024,7 +1029,14 @@ public abstract class Entity
|
|||
for (var i = 0; i < _activeConsumables.Count; i++)
|
||||
{
|
||||
_activeConsumables[i].Update(delta);
|
||||
if(_activeConsumables[i].RemainingDuration < 0) _activeConsumables.RemoveAt(i--);
|
||||
if (_activeConsumables[i].RemainingDuration < 0)
|
||||
{
|
||||
// Cut 2 Gate 1 fix (docs/stats-and-power-cut.md): an expired consumable dropped out of this
|
||||
// list without ever telling the resolver, leaving its generation/cache/modifier entries
|
||||
// reachable (keyed by this ConsumableItemEffect instance) for the rest of the process.
|
||||
Resolver.Forget(_activeConsumables[i]);
|
||||
_activeConsumables.RemoveAt(i--);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var equippedItem in _orderedEquipment)
|
||||
|
|
|
|||
Loading…
Reference in a new issue