From ae0f6f34632061f3e6a676eaf0611ef90c061cb4 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 20 Nov 2026 15:13:37 +0100 Subject: [PATCH] Stance follows the telemetry claim: pin it, and correct the Hated test's comment StanceFollowsTheClaimNotTheLiveFaction changes ships' actual factions after they were tracked; reading other.Faction in the Hated branch instead of the claim now fails it (verified by mutation). HatedIsKillOnSightInAnOwnerlessZone no longer claims that kill. Note on the previous commit's catalog re-save: besides the 16 Faction schema ids, the records' Places arrays gained persisted element ids, which the payload comparison (element ids not serialised in it) did not show. Accepted low resave-payload-claim-loose. The player arm of GetFactionRelationship needs an entity to regard: follow-up regard-player-arm. Co-Authored-By: Claude Sonnet 5.5 --- .../IffAndCombatTests.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/Aetheria.Shared.Tests/IffAndCombatTests.cs b/tests/Aetheria.Shared.Tests/IffAndCombatTests.cs index c7c146927..2d44b8ebb 100644 --- a/tests/Aetheria.Shared.Tests/IffAndCombatTests.cs +++ b/tests/Aetheria.Shared.Tests/IffAndCombatTests.cs @@ -462,7 +462,7 @@ public sealed class IffAndCombatTests : IDisposable } // Hated is kill on sight in any zone, owned or not, once the claim is received with the track; it is directed, so B's stance - // toward A reads B's map. Kills: no Hated branch; reading the regarded side's map; reading other.Faction instead of the claim. + // toward A reads B's map. Kills: no Hated branch; reading the regarded side's map. [Fact] public void HatedIsKillOnSightInAnOwnerlessZone() { @@ -528,4 +528,28 @@ public sealed class IffAndCombatTests : IDisposable Assert.False(ship.IsHostileTo(stranger)); } + + // Stance follows the faction the contact claimed when it was tracked, not the faction it flies now. Kills: reading other.Faction + // instead of the telemetry claim. + [Fact] + public void StanceFollowsTheClaimNotTheLiveFaction() + { + var (items, zone) = BuildWorld(); + var (a, b) = Rivals(items, zone, FactionRelationship.Hated); + var other = new Faction { Name = "C" }; + items.ItemData.Upsert(other); + var neutral = NewShip(items, zone, other); + + Detect(a, b); + Detect(a, neutral); + Assert.True(a.IsHostileTo(b)); + Assert.False(a.IsHostileTo(neutral)); + + var hated = b.Faction; + b.Faction = other; // each keeps what it claimed when tracked, until it is claimed again + neutral.Faction = hated; + + Assert.True(a.IsHostileTo(b)); + Assert.False(a.IsHostileTo(neutral)); + } }