From 8dddda4d80ad7af0b3a6d8fc70edb6b2737f7b6b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 19 Sep 2026 06:02:08 +0200 Subject: [PATCH] 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 --- tests/mutation_tests_stats_power_cut3.py | 24 +++++++++++++++--------- tests/mutation_tests_stats_power_cut4.py | 13 ++++++++++--- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/tests/mutation_tests_stats_power_cut3.py b/tests/mutation_tests_stats_power_cut3.py index 47142254e..b4184918c 100644 --- a/tests/mutation_tests_stats_power_cut3.py +++ b/tests/mutation_tests_stats_power_cut3.py @@ -75,20 +75,26 @@ MUTATIONS: list[Mutation] = [ # --- Cut 3 verification bullet 3 (ยง0.5): "two ships with identical loadouts fitted in opposite equip order # --- get identical grants. That is the death of the hidden priority." The invariant that makes equip order - # --- unable to matter is that every consuming item reads back the SAME GrantRatio; restricting the write to - # --- only the first equipped consumer reintroduces exactly the "whoever equipped first" priority the cut - # --- kills, just relocated from SortPosition into this loop. --- + # --- unable to matter is that every consuming item reads back its own tier's GrantRatio; restricting the + # --- write to only the first draw found reintroduces exactly the "whoever equipped first" priority the cut + # --- kills, just relocated from SortPosition into this loop. + # --- + # --- F8 (docs/stats-and-power-cut.md, Soul pass 2026-09-19) re-anchor: Cut 3's own flat "write GrantRatio to + # --- every consumer" loop (Step) was replaced by Cut 5's tiered AllocateTiers, whose closing loop writes each + # --- draw's own tier ratio instead -- the anchor below follows that move; the rule and the test it's pinned + # --- against (EveryConsumingItemReadsTheSameGrantRatio, a single-tier fixture) are unchanged. --- Mutation( - rule="every consuming item must be written the same GrantRatio, not just the first one found", + rule="every consuming item must be written its own tier's GrantRatio, not just the first draw found", file="Assets/Scripts/ServerShared/PowerBus.cs", anchor=( - " foreach (var item in _entity.Equipment)\n" - " if (item.Behaviors.Any(b => b is IPowerConsumer))\n" - " item.PowerSupply = GrantRatio;" + " foreach (var draw in draws)\n" + " {\n" + " draw.Item.PowerSupply = ratios[draw.Tier];" ), mutated=( - " var firstConsumer = _entity.Equipment.FirstOrDefault(item => item.Behaviors.Any(b => b is IPowerConsumer));\n" - " if (firstConsumer != null) firstConsumer.PowerSupply = GrantRatio;" + " foreach (var draw in draws.Take(1))\n" + " {\n" + " draw.Item.PowerSupply = ratios[draw.Tier];" ), test="PowerBusTests.EveryConsumingItemReadsTheSameGrantRatio", expect="red", diff --git a/tests/mutation_tests_stats_power_cut4.py b/tests/mutation_tests_stats_power_cut4.py index ea6b0c92a..e61f973f1 100644 --- a/tests/mutation_tests_stats_power_cut4.py +++ b/tests/mutation_tests_stats_power_cut4.py @@ -116,12 +116,19 @@ MUTATIONS: list[Mutation] = [ # --- Shield is the map's named exception: a hit is not a chosen activation, so its reserve is a continuous # --- one that may absorb an arbitrary fraction of a hit's cost, unlike a weapon's shot (always spent # --- whole). Requiring a hit to cover the WHOLE reserve before absorbing anything collapses that - # --- distinction back into an activation buffer, which the map explicitly says not to give it. --- + # --- distinction back into an activation buffer, which the map explicitly says not to give it. + # --- + # --- F8 (docs/stats-and-power-cut.md, Soul pass 2026-09-19) re-anchor: the shield reserve ruling + # --- (2026-09-19) gave Shield a Broken state, splitting CanTakeHit's old single-expression body + # --- (`return Item == null || _reserve.CanSpend(...)`) into an Item-null check, a Broken check, and this + # --- CanSpend call as its own line; F5 (the same Soul pass) then made the whole method a pure query. The + # --- rule under test -- CanSpend reads the hit's own cost, not a full-reserve requirement -- is unchanged + # --- and still reachable from this same line. --- Mutation( rule="the shield reserve must allow a partial draw, not require a full reserve before absorbing a hit", file="Assets/Scripts/ServerShared/Behaviors/Shield.cs", - anchor=" return Item == null || _reserve.CanSpend(damage * EnergyUsage);", - mutated=" return Item == null || _reserve.CanSpend(_reserve.Capacity);", + anchor=" return _reserve.CanSpend(damage * EnergyUsage);", + mutated=" return _reserve.CanSpend(_reserve.Capacity);", test="InputCapacitorTests.ShieldReserveAllowsAPartialDrawButRefusesAHitItCannotFullyCover", expect="red", ),