fix(launcher): Campaign LA LA3 review fixes — contract paths omission, probe composition, graceful stop, hygiene
Opus review of LA3 returned FIX FIRST; this addresses every finding in
scope (F1-F5, F7-F12; F6 CI-lane addition excluded per instructions):
- F1 (CRITICAL): SessionProcessSettings.Paths is now nullable and left
null by SessionConfigComposer unless a caller supplies overrides, so
the JSON key is entirely absent instead of "paths":{} — the App-side
loader's strict UnmappedMemberHandling.Disallow would otherwise reject
every gui/guiSelect session-config document at load.
- F2: added SessionConfigComposer.ComposeProbe and a nullable
SessionDescriptor.Mode field ("probe", omitted for normal play) per
the pinned contract — no character/policy/plugins/loginCommands.
- F3: LauncherProcessSupervisor.Stop now tries
ILauncherChildProcess.TryRequestGracefulStop (Linux: libc SIGINT via
LibraryImport, K4-proven graceful headless logout) before
CloseMainWindow. Windows has no reliable no-window-console equivalent
today; filed docs/ISSUES.md #397 with the CREATE_NEW_PROCESS_GROUP +
CTRL_BREAK fix direction. Stop()'s blocking-timeout contract is now
documented for LA4.
- F4: LauncherProfileStore.Save chmods the Linux temp file to 0600
immediately after creation, before any credential is serialized;
failure paths and Load() clean up a stale .tmp.
- F5: added LauncherCoreDependencyBoundaryTests asserting Launcher.Core
references exactly AcDream.Platform and no packages.
- F7: StatusEventParser.Parse no longer throws on a whitespace/null
line; StatusFileTailer.ReadNewEvents swallows the File.Exists/open
TOCTOU window (FileNotFoundException/DirectoryNotFoundException/
IOException) instead of throwing.
- F8: Start() now kills (entire process tree) and disposes a child that
started successfully but failed while being fed its stdin password,
instead of orphaning it.
- F9: SetState is monotonic — once Exited, no later transition applies
or fires StateChanged, closing a Start()-path race where a
synchronously-exiting child could be "resurrected" to Running.
- F10: CharacterIdFormat.TryParse now requires the "0x" prefix (an
unprefixed hand-typed decimal id is also valid hex and was silently
misread); a parsed id of 0 is treated as unusable and falls back to
the name selector; LauncherProfileStore.MergeRoster normalizes both
sides through TryParse/ToHexString instead of raw string equality, so
a legacy unprefixed-hex row self-heals via name match instead of
duplicating.
- F11: StatusCharacterEntry.SecondsGreyedOut is now uint, matching
CharacterRosterEntry and the host writer.
- F12: added MalformedStatusEvent, returned for a recognized `e` whose
payload doesn't match its shape, distinguished from UnknownStatusEvent
(an unrecognized `e`).
AllowUnsafeBlocks was added to AcDream.Launcher.Core.csproj — required
by the LibraryImport source generator's function-pointer marshalling
stub for F3's Linux SIGINT P/Invoke.
Verification: dotnet build AcDream.slnx -c Release green (0 errors);
dotnet test tests/AcDream.Launcher.Core.Tests -c Release green at 94/94
on native Windows and under WSL (Ubuntu, verified across multiple runs
for the timing-sensitive SIGINT/sharing-violation tests, no flakes
observed).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
37d74e4402
commit
26feba8186
19 changed files with 1101 additions and 105 deletions
|
|
@ -0,0 +1,79 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AcDream.Launcher.Core.Tests;
|
||||
|
||||
// Campaign LA plan §LA3 review finding F5: AcDream.Launcher.Core's entire
|
||||
// premise (spec §LA3, SessionConfigDocument.cs's "PINNED CONTRACT" remarks)
|
||||
// is being the BCL-plus-Platform-only assembly the external Avalonia
|
||||
// launcher (LA4) can reference without pulling in any game-solution
|
||||
// dependency. That contract is what this guard enforces — the csproj must
|
||||
// declare exactly one ProjectReference (AcDream.Platform) and zero
|
||||
// PackageReference entries, forever, in the same spirit as Platform's,
|
||||
// Runtime's, and Headless's dependency-boundary guards.
|
||||
public sealed class LauncherCoreDependencyBoundaryTests
|
||||
{
|
||||
[Fact]
|
||||
public void LauncherCoreProjectReferencesOnlyPlatformAndDeclaresNoPackages()
|
||||
{
|
||||
string repositoryRoot = FindRepositoryRoot();
|
||||
string projectPath = Path.Combine(
|
||||
repositoryRoot,
|
||||
"src",
|
||||
"AcDream.Launcher.Core",
|
||||
"AcDream.Launcher.Core.csproj");
|
||||
var project = XDocument.Load(projectPath);
|
||||
|
||||
var projectReferences = project.Descendants("ProjectReference")
|
||||
.Select(element => element.Attribute("Include")?.Value)
|
||||
// The csproj is authored with Windows-style "..\Foo\Foo.csproj"
|
||||
// separators; Path.GetFileName only recognizes the platform's
|
||||
// own separator, so on Linux it would return the whole
|
||||
// relative path unchanged instead of just the filename.
|
||||
// Normalizing to '/' first keeps this assertion
|
||||
// platform-agnostic (this project's tests run under both
|
||||
// native Windows and WSL — see Campaign LA plan §LA3 review
|
||||
// finding F5's acceptance).
|
||||
.Select(include => include is null
|
||||
? null
|
||||
: Path.GetFileName(include.Replace('\\', '/')))
|
||||
.ToList();
|
||||
|
||||
Assert.Equal(["AcDream.Platform.csproj"], projectReferences);
|
||||
Assert.Empty(project.Descendants("PackageReference"));
|
||||
}
|
||||
|
||||
private static string FindRepositoryRoot(
|
||||
[CallerFilePath] string sourcePath = "")
|
||||
{
|
||||
string[] starts =
|
||||
{
|
||||
Path.GetDirectoryName(sourcePath) ?? string.Empty,
|
||||
Directory.GetCurrentDirectory(),
|
||||
AppContext.BaseDirectory,
|
||||
};
|
||||
foreach (string start in starts)
|
||||
{
|
||||
if (string.IsNullOrEmpty(start))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var directory = new DirectoryInfo(start);
|
||||
while (directory is not null)
|
||||
{
|
||||
if (File.Exists(Path.Combine(
|
||||
directory.FullName,
|
||||
"AcDream.slnx")))
|
||||
{
|
||||
return directory.FullName;
|
||||
}
|
||||
|
||||
directory = directory.Parent;
|
||||
}
|
||||
}
|
||||
|
||||
throw new DirectoryNotFoundException(
|
||||
"Could not find AcDream.slnx above the source, working, or output directory.");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue