fix(chat): CH3 review fixes — phantom UN-9, allegiance-broadcast echo, /a legacy fallback

Applies the Opus review of Campaign CH slice CH3 (614a1e05):

- B1: UN-9 was a phantom divergence — ACE's CharacterOptions1.cs:47
  OR-sum is 0x50C4A54A (its own comment confirms 1355064650), identical
  to acdream's literal. The wrong 0x50C48D4A existed only in the research
  doc. Row deleted, register §5 reverted to 4 rows, research doc corrected
  with dated notes.
- S1/S4: AllegianceBroadcast (0x02000000) is a server-echoing channel —
  ACE's GameActionChatChannel handler includes the sender in its real-name
  Allegiance.Members broadcast (retail's DoAllegianceBroadcast has no
  AddTextToScroll), so the client must skip its local optimistic echo, not
  keep it. ChatChannelInfo.Legacy.IsSelfEchoChannel() now returns true for
  it; RouteLegacyChannel's comment corrected; Turbine.IsSelfEchoChannel()'s
  backwards comment rewritten truthfully.
- S3: retail's /a stays on the legacy AllegianceBroadcast bitflag until
  StartupTurbineChatSystem successfully starts Turbine chat — "never
  started" (TurbineChatState.Enabled == false) now falls back to legacy in
  both LiveSessionCommandRouter.RouteChat and
  DirectGameRuntimeCommandAdapter.TrySendChannel, while "enabled but no
  allegiance room" still correctly refuses locally.
- S5: added a LiveSessionEventRouter test proving the Options.Replace ->
  OnCharacterOptionsChanged seeding order, and RuntimeSettingsTargets /
  GameWindowLiveSessionOwnershipTests tests proving the concrete
  ICommandBus.Publish wiring and the single LiveSessionCommandSurface
  construction site.
- S6: AP-181 rewritten to name both of retail's omitted pre-send checks
  (IsMessageSafe silent-drop, then IsMessageSpam) and stop misattributing
  either to RouteLegacyChannel, which has no such gates.
- N1-N7: CharacterOptionId moved below SocialActions so its doc comment
  re-attaches; TurbineChatMembershipGate reuses TurbineChatDisplayNames
  instead of a duplicate table; the gate-to-refusal-text mapping is now
  shared via TurbineChatMembershipGate.ResolveRefusalText instead of
  duplicated in both hosts; ChatSettings.Default now matches ACE's real
  CharacterOptions2.Default (Roleplay/Society start off); a doc-comment
  clarifies only the five Hear toggles are server-backed; the register's
  §3 header recounted 129 -> 128.

Suite: 11,964 passed / 4 skipped / 0 failed (baseline 11,957/4/0 + 7 new
tests). Campaign ledger CH3 review column updated to APPROVE-WITH-FIXES.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-09 20:24:29 +02:00
parent d3f1c21835
commit e07fba5731
21 changed files with 582 additions and 153 deletions

View file

@ -174,19 +174,29 @@ public sealed class LiveSessionCommandRouterTests
}
[Fact]
public void AllegianceWithNoRoom_RefusesLocally_NeverDowngradesToLegacyChannel()
public void AllegianceTurbineEnabledButNoRoom_RefusesLocally_NeverDowngradesToLegacyChannel()
{
// The CH3 headline /a bug (research doc §5.3): retail's @a is bound
// unconditionally to Turbine — no allegiance must refuse locally,
// NOT silently fall through to the legacy AllegianceBroadcast
// bitflag.
// S3 (CH3 Opus review, 2026-08-09) corrected the original CH3
// headline /a fix (research doc §5.3): retail's @a is bound to
// Turbine only once StartupTurbineChatSystem succeeds — i.e. once
// Turbine chat is ENABLED. With Turbine up but no allegiance room
// (this test), retail hits SendTurbineChat's own roomId<=0 branch
// and refuses locally — it must NOT fall through to the legacy
// AllegianceBroadcast bitflag. (Contrast the Enabled==false case
// below, which DOES fall back — Turbine was never started at all.)
var communication = new RuntimeCommunicationState();
var legacySent = new List<(uint Id, string Text)>();
var turbineSent = new List<string>();
var turbine = new TurbineChatState();
turbine.OnChannelsReceived(
allegianceRoom: 0u, generalRoom: 0x70000001u, tradeRoom: 0u,
lfgRoom: 0u, roleplayRoom: 0u, olthoiRoom: 0u, societyRoom: 0u,
societyCelestialHandRoom: 0u, societyEldrytchWebRoom: 0u,
societyRadiantBloodRoom: 0u); // Enabled = true, AllegianceRoom stays 0
var router = NewRouter(
chat: communication.Chat,
communication: communication,
turbine: new TurbineChatState(), // AllegianceRoom stays 0
turbine: turbine,
sendChannel: (id, text) => legacySent.Add((id, text)),
sendTurbine: (_, _, _, _, text, _) => turbineSent.Add(text));
router.Activate();
@ -201,10 +211,40 @@ public sealed class LiveSessionCommandRouterTests
}
[Fact]
public void AllegianceBroadcast_AbVerbChannel_RoutesLegacyWithSelfEcho()
public void AllegianceTurbineNeverStarted_FallsBackToLegacyAllegianceBroadcast()
{
// S3 (CH3 Opus review, 2026-08-09): retail's BASE binding keeps /a
// on the legacy AllegianceBroadcast (0x02000000) channel until
// Turbine chat successfully starts and StartupTurbineChatSystem
// rebinds it (research doc §4.3) — with NO 0x0295
// SetTurbineChatChannels ever received, retail does not print
// "Turbine chat is not available." (that refusal only exists once
// the Turbine-bound verb has actually been armed).
var chat = new ChatLog();
var legacySent = new List<(uint Id, string Text)>();
var turbineSent = new List<string>();
var router = NewRouter(
chat: chat,
turbine: new TurbineChatState(), // never received SetTurbineChatChannels
sendChannel: (id, text) => legacySent.Add((id, text)),
sendTurbine: (_, _, _, _, text, _) => turbineSent.Add(text));
router.Activate();
router.Publish(new SendChatCmd(ChatChannelKind.Allegiance, null, "guild hi"));
Assert.Equal([(0x02000000u, "guild hi")], legacySent);
Assert.Empty(turbineSent);
// S1: AllegianceBroadcast is now a server-echoing channel — no
// local optimistic echo.
Assert.Equal(0, chat.Count);
}
[Fact]
public void AllegianceBroadcast_AbVerbChannel_RoutesLegacyWithNoLocalEcho()
{
// /ab (retail DoAllegianceBroadcast) rides the legacy 0x0147 pipe —
// distinct from /a, which is always Turbine now.
// distinct from /a, which routes through Turbine whenever Turbine
// chat is enabled (see the two Allegiance tests above).
var chat = new ChatLog();
var legacySent = new List<(uint Id, string Text)>();
var router = NewRouter(
@ -216,13 +256,10 @@ public sealed class LiveSessionCommandRouterTests
ChatChannelKind.AllegianceBroadcast, null, "to the whole allegiance"));
Assert.Equal([(0x02000000u, "to the whole allegiance")], legacySent);
Assert.Collection(
chat.Snapshot(),
entry =>
{
Assert.Equal(ChatKind.Channel, entry.Kind);
Assert.Equal("Allegiance", entry.ChannelName);
});
// S1 (CH3 Opus review): ACE's GameActionChatChannel handler
// includes the sender in its real-name Allegiance.Members
// broadcast, so the client must NOT also echo locally.
Assert.Equal(0, chat.Count);
}
// ── Campaign CH slice CH3: per-channel self-echo matrix ──
@ -252,8 +289,15 @@ public sealed class LiveSessionCommandRouterTests
}
[Fact]
public void AllegianceBroadcast_KeepsLocalOptimisticEcho()
public void AllegianceBroadcast_SkipsLocalOptimisticEcho()
{
// S1 (CH3 Opus review, 2026-08-09): flips this test's original
// (wrong) premise. ACE's GameActionChatChannel handler iterates
// player.Allegiance.Members — the sender IS a member, so their own
// line comes back with their real name through the SAME broadcast
// every other member gets. Retail agrees:
// ClientCommunicationSystem::DoAllegianceBroadcast @0x005761F0 has
// no AddTextToScroll of its own. Keeping a local echo double-prints.
var chat = new ChatLog();
var router = NewRouter(
chat: chat,
@ -263,9 +307,7 @@ public sealed class LiveSessionCommandRouterTests
router.Publish(new SendChatCmd(
ChatChannelKind.AllegianceBroadcast, null, "hi"));
Assert.Equal(1, chat.Count); // real-name broadcast includes the
// sender — no separate "" echo, so the
// client keeps its own.
Assert.Equal(0, chat.Count);
}
[Fact]