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>
165 lines
5.8 KiB
C#
165 lines
5.8 KiB
C#
using System.Reflection;
|
|
using AcDream.App.Rendering;
|
|
using AcDream.App.Net;
|
|
using AcDream.Core.Net;
|
|
using AcDream.Runtime;
|
|
using AcDream.Runtime.Session;
|
|
|
|
namespace AcDream.App.Tests.Net;
|
|
|
|
public sealed class GameWindowLiveSessionOwnershipTests
|
|
{
|
|
private const BindingFlags PrivateInstance =
|
|
BindingFlags.Instance | BindingFlags.NonPublic;
|
|
|
|
[Fact]
|
|
public void GameWindowRetainsCanonicalRuntimeAndFocusedHostButNoMirroredSession()
|
|
{
|
|
FieldInfo[] fields = typeof(GameWindow).GetFields(PrivateInstance);
|
|
|
|
Assert.Contains(
|
|
fields,
|
|
field => field.Name == "_runtime"
|
|
&& field.FieldType == typeof(GameRuntime));
|
|
Assert.Contains(
|
|
fields,
|
|
field => field.Name == "_liveSessionHost"
|
|
&& field.FieldType == typeof(LiveSessionHost));
|
|
Assert.DoesNotContain(
|
|
fields,
|
|
field => field.Name == "_liveSessionController"
|
|
|| field.FieldType == typeof(LiveSessionController));
|
|
Assert.DoesNotContain(fields, field => field.Name == "_liveSession");
|
|
Assert.DoesNotContain(fields, field => field.FieldType == typeof(WorldSession));
|
|
Assert.DoesNotContain(fields, field => field.FieldType == typeof(LiveSessionResetPlan));
|
|
Assert.DoesNotContain(fields, field => field.Name == "_liveSessionEvents");
|
|
Assert.DoesNotContain(fields, field => field.Name == "_liveSessionCommands");
|
|
}
|
|
|
|
[Fact]
|
|
public void GraphicalSessionSourceBorrowsCanonicalRuntimeState()
|
|
{
|
|
FieldInfo[] fields = typeof(LiveSessionAppSource).GetFields(PrivateInstance);
|
|
|
|
Assert.Equal(2, fields.Length);
|
|
Assert.Contains(
|
|
fields,
|
|
field => field.Name == "_session"
|
|
&& field.FieldType == typeof(LiveSessionController));
|
|
Assert.Contains(
|
|
fields,
|
|
field => field.Name == "_commands"
|
|
&& field.FieldType == typeof(LiveSessionCommandSurface));
|
|
Assert.DoesNotContain(fields, field => field.FieldType == typeof(WorldSession));
|
|
Assert.DoesNotContain(fields, field => field.FieldType == typeof(bool));
|
|
Assert.DoesNotContain(
|
|
fields,
|
|
field => field.FieldType == typeof(RuntimeGenerationToken)
|
|
|| field.FieldType == typeof(ulong));
|
|
}
|
|
|
|
[Fact]
|
|
public void ProductionWindowConstructsOnlyTheCanonicalRuntimeRoot()
|
|
{
|
|
string root = FindRepositoryRoot();
|
|
string source = File.ReadAllText(Path.Combine(
|
|
root,
|
|
"src",
|
|
"AcDream.App",
|
|
"Rendering",
|
|
"GameWindow.cs"));
|
|
|
|
Assert.Equal(
|
|
1,
|
|
CountOccurrences(source, "new GameRuntime("));
|
|
Assert.Contains(
|
|
"private readonly GameRuntime _runtime;",
|
|
source,
|
|
StringComparison.Ordinal);
|
|
Assert.Contains(
|
|
"_runtimeHostLease = _runtime.AcquireHostLease(",
|
|
source,
|
|
StringComparison.Ordinal);
|
|
string[] forbidden =
|
|
[
|
|
"new RuntimeEntityObjectLifetime(",
|
|
"new RuntimeInventoryState(",
|
|
"new RuntimeCharacterState(",
|
|
"new RuntimeCommunicationState(",
|
|
"new RuntimeActionState(",
|
|
"new RuntimeLocalPlayerMovementState(",
|
|
"new RuntimeWorldTransitState(",
|
|
"new LiveSessionController(",
|
|
"new GameRuntimeClock(",
|
|
];
|
|
Assert.All(
|
|
forbidden,
|
|
value => Assert.DoesNotContain(
|
|
value,
|
|
source,
|
|
StringComparison.Ordinal));
|
|
}
|
|
|
|
[Fact]
|
|
public void ProductionSourceConstructsOnlyOneLiveSessionCommandSurface()
|
|
{
|
|
// CH3 review S5(b): LiveSessionCommandSurface has no dependencies of
|
|
// its own — CH3 deliberately hoisted its single construction site
|
|
// (SessionPlayerComposition.cs) so RuntimeSettingsTargets and the
|
|
// retained UI's chat/inventory panels share the SAME generation-
|
|
// gated command route. A second construction site anywhere under
|
|
// src/AcDream.App would silently split that route into two, each
|
|
// with its own activation/dispose lifecycle.
|
|
string root = FindRepositoryRoot();
|
|
string appRoot = Path.Combine(root, "src", "AcDream.App");
|
|
|
|
int total = Directory
|
|
.EnumerateFiles(appRoot, "*.cs", SearchOption.AllDirectories)
|
|
.Sum(path => CountOccurrences(
|
|
File.ReadAllText(path),
|
|
"new LiveSessionCommandSurface("));
|
|
|
|
Assert.Equal(1, total);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("TryStartLiveSession")]
|
|
[InlineData("ClearInboundEntityState")]
|
|
[InlineData("WireLiveSessionEvents")]
|
|
[InlineData("DisposeLiveSessionRouting")]
|
|
[InlineData("CreateLiveSessionBinding")]
|
|
[InlineData("ApplyLiveSessionSelection")]
|
|
[InlineData("ApplyLiveSessionEnteredWorld")]
|
|
public void DisplacedLifecycleBodiesAreAbsent(string methodName)
|
|
{
|
|
Assert.Null(typeof(GameWindow).GetMethod(methodName, PrivateInstance));
|
|
}
|
|
|
|
private static int CountOccurrences(string source, string value)
|
|
{
|
|
int count = 0;
|
|
int cursor = 0;
|
|
while ((cursor = source.IndexOf(
|
|
value,
|
|
cursor,
|
|
StringComparison.Ordinal)) >= 0)
|
|
{
|
|
count++;
|
|
cursor += value.Length;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
private static string FindRepositoryRoot()
|
|
{
|
|
var current = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (current is not null)
|
|
{
|
|
if (File.Exists(Path.Combine(current.FullName, "AcDream.slnx")))
|
|
return current.FullName;
|
|
current = current.Parent;
|
|
}
|
|
|
|
throw new DirectoryNotFoundException("AcDream.slnx was not found.");
|
|
}
|
|
}
|