Commit graph Aetheria/tests/mutation_tests_stats_power_cut3.py
Author SHA1 Message Date
Meta Vens
8dddda4d80 F8: re-anchor cut3/cut4 mutation harnesses after later cuts moved their code
Both scripts aborted with "anchor must occur exactly once, found 0" -- later
cuts moved the code their anchors pinned:

- cut3's fourth mutation anchored PowerBus.Step's old flat "write GrantRatio
  to every consumer" loop, which Cut 5 replaced with AllocateTiers' own
  tiered closing loop (draw.Item.PowerSupply = ratios[draw.Tier]). Re-anchored
  to that loop; the rule (every draw gets written, not just the first) and
  its test (PowerBusTests.EveryConsumingItemReadsTheSameGrantRatio, a
  single-tier fixture) are unchanged.
- cut4's shield mutation anchored CanTakeHit's old single-expression body
  (`return Item == null || _reserve.CanSpend(...)`), which the 2026-09-19
  shield reserve ruling split into an Item-null check, a Broken check and
  this CanSpend call as its own line, and F5 (this same pass) then made the
  whole method a pure query. Re-anchored to the CanSpend line; the rule (a
  partial draw is allowed, not gated on covering the whole reserve) and its
  test are unchanged.

Both scripts now run clean end to end against the pinned CultLib worktree:
every mutation kills its named test, the no-op control does not.

Scope note: mutation_tests_stats_power_cut0/1/2 also abort on stale anchors
(spot-checked while re-anchoring cut3/cut4, then the check was cancelled
partway through cut1 once the pattern was clear) -- not touched here, as F8
named only cut3 and cut4.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 06:02:08 +02:00
Meta Vens
8dacabb3d8 Cut 4: input capacitors close the last direct capacitor spend
Deletes Entity.CanSpendCapacitorCharge/TrySpendCapacitorCharge (and the
now-dead _capacitors bookkeeping list that only fed them) -- Cut 3's
named, temporary exception for the four instant draws. InstantWeapon
(both fire sites), Sensor.Ping, and Shield.CanTakeHit/TakeHit now spend
from their own InputCapacitor, filled continuously by PowerBus like
every other IPowerConsumer instead of touching the entity's shared bus
capacitors directly.

InputCapacitor's Capacity/Rate derive from the owning item's Energy and
Cooldown, with an authored-override hook (ChargedWeapon repurposes its
previously-unused ChargeEnergy stat as that override, per the map's own
instruction, rather than adding a new field). A weapon/sensor fire
attempt only ever spends exactly Capacity, so it only ever succeeds at
full charge -- no fractional shot. Shield is the map's named exception:
its reserve is continuous, not an activation buffer, so it allows a
partial draw; its size (no Energy/Cooldown pair exists on Shield) is a
flagged judgment call, not a spec'd formula.

Adds InputCapacitorTests.cs (8 tests) and
mutation_tests_stats_power_cut4.py (7 mutations, all behave as
declared); removes the one PowerBusTests.cs test and Cut 3 mutation
case that exercised the now-deleted Entity methods.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-18 22:52:15 +02:00
Meta Vens
f1fd64ac60 Cut 3: PowerBus replaces TryConsumeEnergy/CanConsumeEnergy
Deletes Entity.CanConsumeEnergy/TryConsumeEnergy and Reactor's own capacitor
draining/filling (the demand-mechanism halves of Reactor.cs:90-141); adds
PowerBus (one per Entity, stepped once per tick before equipment executes),
IPowerConsumer on the five continuous draw sites (EnergyDraw, Thruster,
AetherDrive, Radiator, ConstantWeapon), and EquippedItem.PowerSupply as the
bus's grant ratio. Reactor keeps only its heat/throttle arithmetic, now driven
by PowerBus.NetDraw instead of an accumulator any behaviour could add into.

The four instant draws (InstantWeapon's burst/shot, Sensor's ping, Shield's hit
taken) are out of scope for the bus this cut per the map; they spend capacitor
charge directly and atomically via the new Entity.TrySpendCapacitorCharge/
CanSpendCapacitorCharge, replacing TryConsumeEnergy's old partial-drain-then-
refuse bug for that path too. Named, temporary exception closed by Cut 4.

docs/stats-and-power-cut.md Cut 3.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-18 21:39:38 +02:00